Example for LoRa Communication-Two-to-One Communication
Last revision 2026/01/24
This article explains a two-to-one communication setup using LoRa technology with FireBeetle ESP32 and LoRaWAN modules, including preparation, wiring, coding, and results.
This example demonstrates the second type of one-to-many communication mode: setting nodes with addresses 1 and 2 as transmitters, and the node with address 3 as the receiver, achieving a "two-to-one" communication scenario.
Hardware Preparation
- FireBeetle 2 ESP32-E (SKU: DFR0654) ×3
- Gravity: LoRaWAN Node Module(US915)(DFR1115-915) ×3
- Gravity: DHT11 Temperature and Humidity Sensor (SKU: DFR0067) ×1
- Gravity: UV Sensor (SKU: SEN0540) ×1
- PH2.0-4P Cable ×4
- PH2.0-3P Cable ×1
- USB Data Cable ×3
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 and install the DFRobot_LTR390UV
- Download and install the DFRobot_DHT11
- Download Arduino Library: Click to download DFRobot_LWNode Library and refer to the guide: How to Install a Library?
Wiring Diagram
- Transmitter:

- Receiver:

Sample Code
Transmitter Group 1 Program: Sets the node address to 1 and sends temperature and humidity data to the node with address 3.
#include <DFRobot_LWNode.h>
#include <dht11.h>
dht11 DHT;
#define DHT11_PIN 4
#define FREQ 914900000
DFRobot_LWNode_UART node(1); // Set node address to 1
void setup( void ) {
Serial.begin(115200);
Serial1.begin(9600, SERIAL_8N1, /*rx =*/D6, /*tx =*/D7);
delay(5000);
node.begin(/*communication UART*/&Serial1,/*debug UART*/&Serial);
const uint32_t loraConfig[] = {FREQ, DBM22, 125000, 12}; // Configure LoRa communication parameters
while(!node.setFreq(loraConfig[0]) ||
!node.setEIRP(loraConfig[1]) ||
!node.setBW(loraConfig[2]) ||
!node.setSF(loraConfig[3]) ||
!node.start()) {
Serial.println("LoRa init failed");
delay(2000);
}
}
void loop( void ){
DHT.read(DHT11_PIN); // Read data from the DHT11 temperature and humidity sensor
Serial.print(DHT.humidity,1);
Serial.print(",\t");
Serial.println(DHT.temperature,1);
String DHT11_DATE=String(DHT.humidity)+"%"+" "+String(DHT.temperature) + "℃";
delay(2000);
node.sendPacket(3, DHT11_DATE); // Send temperature and humidity data to the node with address 3
node.sleep(5000);
}
Transmitter Group 2 Program: Sets the node address to 2 and sends UV sensor data to the node with address 3.
#include <DFRobot_LWNode.h>
#define FREQ 914900000
// Initialize LoRa and UV sensor
#include "DFRobot_LTR390UV.h"
DFRobot_LTR390UV ltr390(/*addr = */LTR390UV_DEVICE_ADDR, /*pWire = */&Wire);
DFRobot_LWNode_UART node(2); // Set node address to 2
void setup( void ) {
Serial.begin(115200);
Serial1.begin(9600, SERIAL_8N1, /*rx =*/D6, /*tx =*/D7);
delay(5000);
node.begin(/*communication UART*/&Serial1,/*debug UART*/&Serial);
const uint32_t loraConfig[] = {FREQ, DBM22, 125000, 12}; // LoRa communication parameters
while(!node.setFreq(loraConfig[0]) ||
!node.setEIRP(loraConfig[1]) ||
!node.setBW(loraConfig[2]) ||
!node.setSF(loraConfig[3]) ||
!node.start()) {
Serial.println("LoRa init failed");
delay(2000);
}
// Initialize UV sensor
while(ltr390.begin() != 0){
Serial.println(" Sensor initialize failed!!");
delay(1000);
}
Serial.println(" Sensor initialize success!!");
// Configure UV sensor
ltr390.setALSOrUVSMeasRate(ltr390.e18bit, ltr390.e100ms); // 18-bit data, 100ms sampling
ltr390.setALSOrUVSGain(ltr390.eGain3); // 3x gain
ltr390.setMode(ltr390.eUVSMode); // Set to UV measurement mode
}
void loop(void) {
// Read UV sensor data
uint32_t uv = ltr390.readOriginalData(); // Get raw UV sensor data
Serial.print("UV data: ");
Serial.println(uv);
// Prepare and send UV data to node with address 3
String ltr390_DATE = String(uv);
node.sendPacket(3, ltr390_DATE);
// Sleep to conserve power (adjust if needed)
node.sleep(5000);
}
Receiver Program: Set the receiver node address to 3 and keep it in message receiving mode.
#include <DFRobot_LWNode.h>
#define FREQ 914900000
DFRobot_LWNode_UART node(3); // Set node address to 3
void rxCBFunc(uint8_t from, void *buffer, uint16_t size, int8_t rssi, int8_t snr){
char *p = (char *)buffer;
Serial.print("recv from: ");
Serial.println(from, HEX);
Serial.print("recv data: ");
for(uint8_t i = 0; i < size; i++){
Serial.print(p[i]);
}
Serial.println();
Serial.println("Text:");
Serial.println((char *)buffer);
Serial.print("rssi=");Serial.println(rssi);
Serial.print("snr=");Serial.println(snr);
}
void setup( void ){
Serial.begin(115200);
Serial1.begin(9600, SERIAL_8N1, /*rx =*/D6, /*tx =*/D7);
delay(5000);
node.begin(/*communication UART*/&Serial1,/*debug UART*/&Serial);
const uint32_t loraConfig[] = {FREQ, DBM22, 125000, 12}; // Configure LoRa communication parameters
while(!node.setFreq(loraConfig[0]) ||
!node.setEIRP(loraConfig[1]) ||
!node.setBW(loraConfig[2]) ||
!node.setSF(loraConfig[3]) ||
!node.start()) {
Serial.println("LoRa init failed");
delay(2000);
}
node.setRxCB(rxCBFunc);
}
void loop( void ){
node.sleep(5000);
}
Results
Serial output of transmitter Group 1:

Serial Output of Transmitter Group 2:

Serial Output of Receiver: Data received from Transmitter Group 1 and Group 2.

Was this article helpful?
