Example for LoRaWAN Communication-ABP Network Joining
Last revision 2026/01/24
The article offers a detailed guide on setting up LoRaWAN communication through ABP Network Joining, covering hardware and software preparations, wiring, and sample Arduino codes for effective IoT data transmission.
Hardware Preparation
- FireBeetle 2 ESP32-E (SKU: DFR0654) ×1
- Gravity: LoRaWAN Node Module(EU868)(DFR1115-868) ×1
- PH2.0-4P Cable ×1
- USB Data Cable ×1
Software Preparation
- Download Arduino IDE: Click to Download Arduino IDE
- Install SDK: Visit the FireBeetle 2 ESP32-E WIKI page for SDK installation instructions
- Download Arduino Library: Click to download DFRobot_LWNode Library and refer to the guide: How to Install a Library?
Wiring Diagram
I2C Wiring Diagram (This connection method is used in all the following examples)

Pin Connection Description:
- Node Module: SDA Pin --- (Connects to) --- Main Controller: 21/SDA
- Node Module: SCL Pin --- (Connects to) --- Main Controller: 22/SCL
- Node Module: - Pin --- (Connects to) --- Main Controller: GND
- Node Module: + Pin --- (Connects to) --- Main Controller: 3V3
UART Wiring Diagram

Pin Connection Description:
- Node Module: TX Pin --- (Connects to) --- Main Controller: 14/D6
- Node Module: RX Pin --- (Connects to) --- Main Controller: 13/D7
- Node Module: - Pin --- (Connects to) --- Main Controller: GND
- Node Module: + Pin --- (Connects to) --- Main Controller: 3V3
Sample Code 1
Before using this example, ensure that the gateway is set to manual device addition mode and configured to allow ABP for device registration.
ABP Network Joining and Sending Data to the Gateway.
#include "DFRobot_LWNode.h"
// ABP credentials (replace these with your actual values)
const char NWKSKEY[]={"87888888888888888888888888888888"};
const char APPSKEY[]={"89888888888888888888888888888888"};
uint32_t devAddr = 0xDF000011;
#define REGION EU868
#define DATARATE DR5
DFRobot_LWNode_IIC node(devAddr, NWKSKEY, APPSKEY);
void setup(void) {
Serial.begin(115200);
node.begin(/*communication IIC*/&Wire,/*debug UART*/&Serial);
while(!node.setRegion(REGION)){
delay(2000);
Serial.println("REGION set fail");
}
if (!node.setAppSKey(APPSKEY)) {
Serial.println("APPSKEY set fail");
}
if (!node.setNwkSKey(NWKSKEY)) {
Serial.println("NWKSKEY set fail");
}
if (!node.setDevAddr(devAddr)) {
Serial.println("devAddr set fail");
}
while (!node.setDataRate(DATARATE)) {
delay(2000);
Serial.println("DataRate set fail");
}
while (!node.setEIRP(DBM16)) {
delay(2000);
Serial.println("EIRP set fail");
}
while(!node.enableADR(false)) {
delay(2000);
Serial.println("ADR set fail");
}
while(!node.setPacketType(UNCONFIRMED_PACKET)) {
delay(2000);
Serial.println("Packet type set fail");
}
node.start(); // Start LoRaWAN communication in ABP mode
String deveui = node.getDevEUI();
Serial.print("DEVEUI: ");
Serial.println(deveui);
Serial.print("DATARATE: ");
Serial.println(node.getDataRate());
Serial.print("EIRP: ");
Serial.println(node.getEIRP());
}
void loop() {
node.sendPacket("hello"); // Send a text message "hello" to the LoRaWAN gateway
node.sleep(10 * 1000);
uint8_t buf[3] = {1, 2, 3}; // Send a binary message {1, 2, 3} to the LoRaWAN gateway
node.sendPacket(buf, 3);
node.sleep(10 * 1000);
}
Result
On the node side: The serial monitor shows that the node sends data to the gateway every 10 seconds.

Sample Code 2
Receiving Data from the Gateway via Polling after ABP Network Joining.
#include "DFRobot_LWNode.h"
// ABP credentials (replace these with your actual values)
const char NWKSKEY[]={"87888888888888888888888888888888"} ;
const char APPSKEY[]={"89888888888888888888888888888888"};
uint32_t devAddr = 0xDF000011;
uint8_t buf[256]; // Buffer to store received data
#define REGION EU868
#define DATARATE DR5
DFRobot_LWNode_IIC node(devAddr,NWKSKEY,APPSKEY);
void setup(void){
Serial.begin(115200);
delay(5000);
node.begin(/*communication IIC*/&Wire,/*debug UART*/&Serial);
while(!node.setRegion(REGION)){
delay(2000);
Serial.println("REGION set fail");
}
while(!node.setDevType(CLASS_C)){
delay(2000);
Serial.println("DevType set fail");
}
String deveui = node.getDevEUI();
Serial.print("DEVEUI: ");
Serial.println(deveui);
// Start LoRaWAN communication in ABP mode
node.start();
Serial.println("join success");
}
void loop(){
uint8_t len = node.readData(buf); // Check if there is data received from the gateway
if(len > 0){
Serial.print("\nreceive ");
Serial.print(len);
Serial.println(" bytes \nHEX:");
for(uint8_t i = 0; i < len; i++){
Serial.print(buf[i],HEX); // Print received data in hexadecimal format
}
Serial.println();
Serial.println("Text:"); // Print received data as text
Serial.println((char *)buf);
}
node.sleep(500);
}
Result
On the node side: The serial monitor displays the message "join success", and the node enters a polling state to check whether data is received from the buffer.

Was this article helpful?
