OTAA-based LoRaWAN Node with Arduino & LoRa SX1276
DIY OTAA-based LoRaWAN End Node with Arduino LoRa Module SX1276 & registering with The Things Network Server using IBM LMIC Framework library
- Suitable forB.Tech/Diploma LoRa/IoT students
- Build time1-2 weeks
- LevelBeginner
- Available atAjvika Labs, Kakinada
About this project
Overview
In this article, we will learn how we can create an
OTAA
-based
LoRaWAN Node
with Arduino &
LoRa Module SX1276
. In previous tutorial, we learned how to setup Dragino
LPS8 LoRaWAN Gateway
with The Things Network Server. We also learned about the
Ra-07 LoRaWAN Node
and the method to send sensor data to
The Things Network Server
using the
LoRaWAN Gateway
This tutorial covers the method to develop a
DIY LoRaWAN End Node
which can be activated in
OTAA mode
using the
SX1276 LoRa module
and
Arduino Pro Mini
. The node can publish a “
hello world!
” message to The Things Network Dashboard. The data being transmitted over the LoRaWAN is encrypted, so we will learn how to decrypt that data to read the message in a readable format. Check the earlier post to learn how you make
ABP Based LoRaWAN Node
for activating via ABP Method.
Bill of Materials
We can use a breadboard to test the LoRaWAN product, so following materials can be purchased from the given Amazon link.
S.N.
Components Name
Quantity
Purchase Links
Arduino Pro Mini 3.3V Board
Amazon
AliExpress
FTDI Module
Amazon
AliExpress
LoRa Module SX1276
Amazon
AliExpress
Connecting Wires
Amazon
AliExpress
Breadboard
Amazon
AliExpress
LoRa Module SX1276
You can use any of the
SX1276-based LoRa chip
which has a frequency of
868MHz
. In case you are using a
915MHz Gateway
, you can use SX1276 with a 915MHz frequency version. In this tutorial, we are using the
LPS8 LoRaWAN gateway
with an
868MHz frequency
The SX1276 is a LoRa chip developed by
Semtech
. The SX1276 incorporates the LoRa spread spectrum modem which is capable of achieving a significantly longer range than existing systems based on FSK or OOK modulation. At maximum data rates of LoRa, the sensitivity is 8dB better than FSK. But using a low-cost bill of materials with a 2Oppm XTAL LoRa can improve receiver sensitivity by more than 20dB compared to FSK.
SX1276 Pinout
In this tutorial we are using SX1276 chip manufactured by
Gplus-IoT
. The Gplus-IoT LoRa Module SX1276 has total 18 pins whose functionalities are as follows:
Designing SX1276 Breakout Board
The Gplus-IoT SX1276 chip is very tiny in size so its very difficult to interface it with any controller. So I designed a small breakout board using EasyEDA software and converted it into a PCB. The PCB layout looks something like this.
The Gerber File for the PCB is given below. You can simply download the Gerber File and order the PCB from
ALLPCB
at
1$
only.
Download Gerber File:
SX1276 Breakout PCB
You can use this Gerber file to order high quality PCB for this project. To do that visit the
ALLPCB
official website by clicking here:
https://www.allpcb.com/
You can now upload the Gerber File by choosing the Quote Now option. From these options, you can choose the Material Type, Dimensions, Quantity, Thickness, Solder Mask Color and other required parameters.
After filling all details, select your country and shipping method. Finally you can place the order.
Then I soldered the SX1276 chip into the PCB. The SX1276 chip has a very small gap between the two consecutive pins. So it requires good soldering skills for soldering the components.
Hardware Setup & Connection
Let us see how we can interface SX1276 LoRa Module with Arduino Pro Mini. The question is why we are using Arduino Pro Mini instead of Arduino UNO or Nano. The reason is that LoRa Chip is an SPI-based chip with a 3.3V logic level. To get the 3.3V logic level, we need to use the Arduino board having 3.3V logic. This logic is provided by Arduino Pro Mini Board.
Here is a connection diagram for interfacing SX1276 LoRa Module with Arduino Board. The connection is fairly simple.
Connect all the SPI Pin of SX1276 to Arduino SPI Pin. We all need to connect at least 2 digital input-output pins of SX1276 to Arduino digital pin. In this circuit, we connected the DIO0, DIO1, and DIO2 of SX1276 to Arduino D3, D4, and D5 Pin respectively. The LoRaWAN hardware doesn’t work in ABP & OTAA Mode if these pins are left unconnected.
ABP vs OTAA Activation Method
The LoRaWAN Nodes can be activated via tow methods as ABP Activation of OTAA Activation. Let us understand the differences between ABP and OTAA activation modes for LoRaWAN end devices.
ABP
In ABP activation, a fixed
DevAddr
and session keys for a pre-selected network are hardcoded into the end device, and they remain the same throughout the lifetime of an ABP end device. With this mode, an end device skips the join procedure which seems to be simpler, but there are quite a few limitations of using ABP.
OTAA
OTAA end devices are provisioned with root keys. In OTAA activation, an end device performs a join procedure with a LoRaWAN network, during which a dynamic
DevAddr
is assigned to an end device, and root keys are utilized to derive session keys. Hence,
DevAddr
and session keys change as each new session is established.
Registation of LoRaWAN Node on The Things Network Server
For transmitting the LoRaWAN Node data to TTN(The Things Network), it is necessary to learn the use of TTN in advance, such as how to set an application & activate LoRaWAN Device via OTAA method. After setting your application of TTN, there are three parameters that are important: Device EUI, APP Key, APP EUI.
Enter the TTN website:
https://console.thethingsnetwork.org/
, and log in your account. Then go to the console, select a cluster to start adding devices. In my case I selected EU cluster.
Select Application on the page and add a new application. Then fill in the application ID and other information, then create it.
Add an End device, select frequency plan, and the LoRaWAN version.
Select manually to choose the active mode for OTAA and LoRaWAN versions, then follow the reminders to type in the parameters. Then generate Device EUI, App EUI and AppKey. Then click on register end devices
Now the end node is successfully created. Hence you can see three parameters that had to be put into the code.
On the device page, it is necessary to set the payload formatters to decode the payload LoRaWAN node transmitted. Choose the Uplink and select the Javascript. Type in the following code and save.
function
Decoder
(
bytes
port
)
{
var
result
=
""
;
for
(
var
i
=
;
i
<
bytes
length
;
i
++
)
{
result
+=
(
String
fromCharCode
(
bytes
[
i
]
)
)
;
}
return
{
text
:
result
}
;
}
Now the TTN application setting is finished.
Source Code & Programming
Now let us program the Arduino Pro Mini to activate the SX1276 Based LoRaWAN node with OTAA method.
For this we will use a readymade library from IBM called as
Arduino-LMIC library
. Download the library from the Github repository and then install it using the add zip library feature in the Arduino IDE.
Now go to the examples from the file menu and search for the IBM LMIC framework and then open the ttn-otaa example.
Before uploading the code, you need to make some changes to the example code. Add Device EUI, APP Key, APP EUI to the following lines.
static
const
u1_t
PROGMEM
APPEUI
[
]
=
{
0x00
0x00
0x00
0x00
0x00
0x00
0x00
0x00
}
;
static
const
u1_t
PROGMEM
DEVEUI
[
]
=
{
0x01
0x00
0x00
0x00
0x00
0x00
0x00
0x00
}
;
static
const
u1_t
PROGMEM
APPKEY
[
]
=
{
0x2B
0x7E
0x15
0x16
0x28
0xAE
0xD2
0xA6
0xAB
0xF7
0x15
0x88
0x09
0xCF
0x4F
0x3C
}
;
Also make changes to the Arduino Pins here.
const
lmic_pinmap
lmic_pins
=
{
nss
=
rxtx
=
LMIC_UNUSED_PIN
rst
=
dio
=
{
}
}
;
You also need to modify some library files to get this code working in case the code fails.
Here is the complete code for the project.
In this article, we will learn how we can create an
OTAA
-based
LoRaWAN Node
with Arduino &
LoRa Module SX1276
. In previous tutorial, we learned how to setup Dragino
LPS8 LoRaWAN Gateway
with The Things Network Server. We also learned about the
Ra-07 LoRaWAN Node
and the method to send sensor data to
The Things Network Server
using the
LoRaWAN Gateway
This tutorial covers the method to develop a
DIY LoRaWAN End Node
which can be activated in
OTAA mode
using the
SX1276 LoRa module
and
Arduino Pro Mini
. The node can publish a “
hello world!
” message to The Things Network Dashboard. The data being transmitted over the LoRaWAN is encrypted, so we will learn how to decrypt that data to read the message in a readable format. Check the earlier post to learn how you make
ABP Based LoRaWAN Node
for activating via ABP Method.
Bill of Materials
We can use a breadboard to test the LoRaWAN product, so following materials can be purchased from the given Amazon link.
S.N.
Components Name
Quantity
Purchase Links
Arduino Pro Mini 3.3V Board
Amazon
AliExpress
FTDI Module
Amazon
AliExpress
LoRa Module SX1276
Amazon
AliExpress
Connecting Wires
Amazon
AliExpress
Breadboard
Amazon
AliExpress
LoRa Module SX1276
You can use any of the
SX1276-based LoRa chip
which has a frequency of
868MHz
. In case you are using a
915MHz Gateway
, you can use SX1276 with a 915MHz frequency version. In this tutorial, we are using the
LPS8 LoRaWAN gateway
with an
868MHz frequency
The SX1276 is a LoRa chip developed by
Semtech
. The SX1276 incorporates the LoRa spread spectrum modem which is capable of achieving a significantly longer range than existing systems based on FSK or OOK modulation. At maximum data rates of LoRa, the sensitivity is 8dB better than FSK. But using a low-cost bill of materials with a 2Oppm XTAL LoRa can improve receiver sensitivity by more than 20dB compared to FSK.
SX1276 Pinout
In this tutorial we are using SX1276 chip manufactured by
Gplus-IoT
. The Gplus-IoT LoRa Module SX1276 has total 18 pins whose functionalities are as follows:
Designing SX1276 Breakout Board
The Gplus-IoT SX1276 chip is very tiny in size so its very difficult to interface it with any controller. So I designed a small breakout board using EasyEDA software and converted it into a PCB. The PCB layout looks something like this.
The Gerber File for the PCB is given below. You can simply download the Gerber File and order the PCB from
ALLPCB
at
1$
only.
Download Gerber File:
SX1276 Breakout PCB
You can use this Gerber file to order high quality PCB for this project. To do that visit the
ALLPCB
official website by clicking here:
https://www.allpcb.com/
You can now upload the Gerber File by choosing the Quote Now option. From these options, you can choose the Material Type, Dimensions, Quantity, Thickness, Solder Mask Color and other required parameters.
After filling all details, select your country and shipping method. Finally you can place the order.
Then I soldered the SX1276 chip into the PCB. The SX1276 chip has a very small gap between the two consecutive pins. So it requires good soldering skills for soldering the components.
Hardware Setup & Connection
Let us see how we can interface SX1276 LoRa Module with Arduino Pro Mini. The question is why we are using Arduino Pro Mini instead of Arduino UNO or Nano. The reason is that LoRa Chip is an SPI-based chip with a 3.3V logic level. To get the 3.3V logic level, we need to use the Arduino board having 3.3V logic. This logic is provided by Arduino Pro Mini Board.
Here is a connection diagram for interfacing SX1276 LoRa Module with Arduino Board. The connection is fairly simple.
Connect all the SPI Pin of SX1276 to Arduino SPI Pin. We all need to connect at least 2 digital input-output pins of SX1276 to Arduino digital pin. In this circuit, we connected the DIO0, DIO1, and DIO2 of SX1276 to Arduino D3, D4, and D5 Pin respectively. The LoRaWAN hardware doesn’t work in ABP & OTAA Mode if these pins are left unconnected.
ABP vs OTAA Activation Method
The LoRaWAN Nodes can be activated via tow methods as ABP Activation of OTAA Activation. Let us understand the differences between ABP and OTAA activation modes for LoRaWAN end devices.
ABP
In ABP activation, a fixed
DevAddr
and session keys for a pre-selected network are hardcoded into the end device, and they remain the same throughout the lifetime of an ABP end device. With this mode, an end device skips the join procedure which seems to be simpler, but there are quite a few limitations of using ABP.
OTAA
OTAA end devices are provisioned with root keys. In OTAA activation, an end device performs a join procedure with a LoRaWAN network, during which a dynamic
DevAddr
is assigned to an end device, and root keys are utilized to derive session keys. Hence,
DevAddr
and session keys change as each new session is established.
Registation of LoRaWAN Node on The Things Network Server
For transmitting the LoRaWAN Node data to TTN(The Things Network), it is necessary to learn the use of TTN in advance, such as how to set an application & activate LoRaWAN Device via OTAA method. After setting your application of TTN, there are three parameters that are important: Device EUI, APP Key, APP EUI.
Enter the TTN website:
https://console.thethingsnetwork.org/
, and log in your account. Then go to the console, select a cluster to start adding devices. In my case I selected EU cluster.
Select Application on the page and add a new application. Then fill in the application ID and other information, then create it.
Add an End device, select frequency plan, and the LoRaWAN version.
Select manually to choose the active mode for OTAA and LoRaWAN versions, then follow the reminders to type in the parameters. Then generate Device EUI, App EUI and AppKey. Then click on register end devices
Now the end node is successfully created. Hence you can see three parameters that had to be put into the code.
On the device page, it is necessary to set the payload formatters to decode the payload LoRaWAN node transmitted. Choose the Uplink and select the Javascript. Type in the following code and save.
function
Decoder
(
bytes
port
)
{
var
result
=
""
;
for
(
var
i
=
;
i
<
bytes
length
;
i
++
)
{
result
+=
(
String
fromCharCode
(
bytes
[
i
]
)
)
;
}
return
{
text
:
result
}
;
}
Now the TTN application setting is finished.
Source Code & Programming
Now let us program the Arduino Pro Mini to activate the SX1276 Based LoRaWAN node with OTAA method.
For this we will use a readymade library from IBM called as
Arduino-LMIC library
. Download the library from the Github repository and then install it using the add zip library feature in the Arduino IDE.
Now go to the examples from the file menu and search for the IBM LMIC framework and then open the ttn-otaa example.
Before uploading the code, you need to make some changes to the example code. Add Device EUI, APP Key, APP EUI to the following lines.
static
const
u1_t
PROGMEM
APPEUI
[
]
=
{
0x00
0x00
0x00
0x00
0x00
0x00
0x00
0x00
}
;
static
const
u1_t
PROGMEM
DEVEUI
[
]
=
{
0x01
0x00
0x00
0x00
0x00
0x00
0x00
0x00
}
;
static
const
u1_t
PROGMEM
APPKEY
[
]
=
{
0x2B
0x7E
0x15
0x16
0x28
0xAE
0xD2
0xA6
0xAB
0xF7
0x15
0x88
0x09
0xCF
0x4F
0x3C
}
;
Also make changes to the Arduino Pins here.
const
lmic_pinmap
lmic_pins
=
{
nss
=
rxtx
=
LMIC_UNUSED_PIN
rst
=
dio
=
{
}
}
;
You also need to modify some library files to get this code working in case the code fails.
Here is the complete code for the project.
Technologies used
Hardware components
- Arduino
- SX1276
Software & tools
- Arduino IDE
- EasyEDA
What you get
- Working project / hardware kit, tested before delivery
- Complete source code with explanation
- Project demo and guidance for your viva
- Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed.
Payment is in two parts:
• 50% advance to start the project
• Remaining 50% before delivery
Note:
• Documentation and PPT are not included by default
• If you need documentation/PPT, it can be arranged for extra time and cost
We'll confirm the exact timeline and cost with you after reviewing your requirements.