This guide will instruct you to create a DIY LoRaWAN node using ESP32, RFM95 module and RadioLib.
- The guide is applicable to all ESP32 variant and RFM95 module with minor difference.
- The guide uses ESP32 Dev Module and RFM95 for 915/923Mhz.
- The node will support LoRaWAN 1.1.0, Class A and uplink/downlink feature. LoRaWAN 1.0.x is still backward supported. Class B and C are not supported yet.
- Product link: ESP32 and RFM95. AIThinker Ra01/02/01h is supported too.
- Source code: From Easy LoRaWAN. This source code has OTAA persistence compared to the sample code of RadioLib. OTAA persistence allows the node to increase OTAA counter during an OTAA join.
ESP32 Dev Module:
HopeRF RFM95
AI-Thinker ra01/02/01h
Step 1: To wire LoRa module to ESP32 as below
- LORA_SS 25 // Must have pull up resistor
- LORA_SCK 18 // Default SCK for VSPI in ESP32
- LORA_MOSI 23 // Default MOSI for VSPI in ESP32
- LORA_MISO 19 // Default MISO for VSPI in ESP32
- LORA_DIO0 26
- LORA_DIO1 35
- LORA_DIO2 34
- LORA_RESET 27
Step 2: Install softwares and libraries
- To install Arduino IDE at here
- To add Arduino support for ESP32: here
- To install UART driver: Check section B2 here
Step 3: To import RadioLib library
Step 4: To download source code at the top of the guide
Step 5: To modify GPIOs to fit your board wiring in config.h
- To use SX1276 for EU868, US915, AU915, AS923, AS923_2, AS923_3 and AS923_4
- To use Sx1278 for CN470
Step 6: To change your JOIN_EUI, APP_KEY, NWK_KEY and Region
Step 7: Upload the code to the node
Step 8: To configure your gateways and LoRaWAN server
- You need to configure your commercial LoRaWAN gateways or your DIY LoRaWAN gateways.
- You need to add your LoRaWAN gateway and node to LoRaWAN server or Easy LoRaWAN Cloud in QuickStart guides.
Step 9: After step 8, you can see the node sending uplink data to server and receiving downlink data from the server.
Enjoy.
Want to test LoRaWAN?
Subscribe Easy LoRaWAN Cloud to try this guide on your LoRaWAN gateways and nodes.
We will help you to get started and troubleshooting.
Thanks for the guides?
If this guide saves your days, you can give us a cup of coffee.
This is one-time donation.
Thank you for supporting us.
What should I choose OTAA or ABP?
ABP seems simpler.
We should always use OTAA.
It is newer and more secure.
Our source code has OTAA persistence compared to the sample code of RadioLib. OTAA persistence allows the node to increase OTAA counter during an OTAA join.
Does this library support Class C?
Not yet.
Currently, Radiolib library only supports Class A.
In the meantime, you can send more uplinks to receive the downlink faster.
Why my downlinks are pending a while in server before getting downloaded to the LoRaWAN node?
Thanks.
The library Radiolib in this guide supports LoRaWAN Class A.
It means the node only downloads the downlink right after an uplink.
So if the node sends an uplink every 30 minutes, then the downlinks will be pending in the server for 30 minutes before getting downloaded to the node.
So for class A, you could send an uplink more frequently to get a downlink faster.
We will update the guide when Radiolib supports Class C (continuous mode).
You can read more about Class A, B and C here
https://iotthinks.com/lorawan-class-a-b-and-c/
Enjoy.
Thanks alot for the guides.
The OTAA is working great.
Great.
Enjoy the guide.
Does this code work with LoRaWAN 1.0.x?
Thanks a lot.
Hi Mark,
RadioLib library officially supports LoRaWAN 1.1.
However, if you want this code to work with LoRaWAN 1.0.x (such as LoRaWAN 1.0.2, 1.0.3 and 1.0.4), in step 6, you put any value to RADIOLIB_LORAWAN_APP_KEY and put your APPKEY into RADIOLIB_LORAWAN_NWK_KEY.
Hope it helps.
Will this DIY node work with my RAK gateway and Dragino gateway?
Thanks in advance.
Hi Jon,
This DIY node will work with ALL LoRaWAN gateways.
You just need to make sure they use the same LoRaWAN regions with your node.
Best regards,
IoTThinks.com
Hi,
Do you have some guides to create a DIY LoRaWAN node using STM32 board?
Thanks a lot.
Hi Kevin,
Ok, we will create a guide for STM32 board using STM32CubeIDE and CubeMX this month.
Keep in touch.
Best regards.