What is LoraWAN?
LoRaWAN is a media access control (MAC) protocol for wide area networks. It is designed to allow low-powered devices to communicate with Internet-connected applications over long-range wireless connections.
LoRaWAN can be mapped to the second and third layers of the OSI model. It is implemented on top of LoRa or FSK modulation in industrial, scientific, and medical (ISM) radio bands. The LoRaWAN protocols are defined by the LoRa Alliance and formalized in the LoRaWAN Specification which can be downloaded on the LoRa Alliance website
Material Required is as follows:
1.ESP32
2.LoRaBEE
3. Gateway
4.The Things Network Account
Circuit Diagram
Pin Details
LoRe BEE |
LoRe BEE physical pin |
ESP32 Pin |
MISO |
4 |
D19(MISO)
|
RESET |
5 |
D14 |
MOSI |
11 |
D23(MOSI) |
D0 |
12 |
D2 |
D1 |
13 |
D26 |
D2 |
14 |
D25 |
NSS |
17 |
D5 |
SCK |
18 |
D22(SCLK) |
3V3 |
1 |
3V3 |
GND |
10 |
GND |
Step 1: Installing ESP32 Add-on in Arduino IDE
- To install the ESP32 board in your Arduino IDE, follow below steps.
- In your Arduino IDE, go to File > Preferences.
- Enter https://dl.espressif.com/dl/package_esp32_index.json into the “Additional Board Manager URLs” field as shown in the figure below. Then, click the “OK” button.
- Go to Tools > Board > Boards Manager.
- Search ESP32 and Click on the install button.
- The installation may take a while depending on your network performance. Once done, close the board manager
Step 2: Setup the Things Network Console Server
To setup up the TTN Console, please check the steps given in the blog: <TODO: add link to Rpi lorawan blog>
Step 3: Code and Library
Download as Zip file of Arduino-lmic Library refer below link
https://github.com/matthijskooijman/arduino-lmic
Installing library
In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library.
At the top of the drop-down list, select the option to "Add. ZIP Library''.
Code: here we are using example sketch ttn-abp
navigate to ttn-abp example
Example sketch: File > Sketchbook > Examples > IBM LMIC framework>ttn-abp
Step 4: Pin Number Modification in Code
Change the pin numbers as shown in the code below
Step 5: Copy your Network Session Key, App Session Key and Device Address from TTN console into your code
You can find all Keys in your TTN console, go to Application > Devices > Your Devices
Make sure Network Session Key and App Session Key are copied in big-endian (MSB) format. To reverse the order, click on the reverse button to the left of the field.
Copy these details to the following lines in the code:
Step 6: Uploading code
- In your Arduino IDE, go to Tools > Board>ESP32 Arduino
- Select the Port
- Click on the Upload button in the Arduino IDE
- After uploading code open Arduino Serial monitor
- After this go to the TTN console > Application > Device > Data
- Here uplink, downlink, and acknowledgment packets will be shown
Step 7: Scheduling Downlink
- Go to TTN console > Application > Device > Overview
- In Downlink section enter your payload in hex format
- Ensure that the “Confirmed” option is selected.
- Click on send
- Once the packet is received, you can see the downlink message in your Arduino Serial monitor
- After the downlink packet is received, you can see acknowledgment notification in the TTN console.
Troubleshooting
After uploading code if you get the Failure error on the Serial monitor
Check your connections to make sure they are correct and not loose. Also, check if all pin numbers are correct.