Example for LoRa Communication-One-to-Many Communication

Last revision 2026/01/24

This article provides a detailed example of implementing LoRa's 'Single Transmit, Multiple Receive' communication mode, including hardware and software setup, wiring diagrams, and sample code for successful data transmission.

There are two types of one-to-many communication modes for nodes:

  1. Single Transmit, Multiple Receive Mode: One node sends data, and multiple nodes receive simultaneously.
  2. Single Receive, Multiple Transmit Mode: One node receives data, and multiple nodes transmit simultaneously.
    This example demonstrates the first type, Single Transmit, Multiple Receive Mode: Node with address 1 is set as the transmitter, and nodes with address 2 and 3 are set as receivers, realizing the "one-to-many" communication scenario.

Hardware Preparation

Software Preparation

Wiring Diagram

Here, UART communication is used.

  • Transmitter:

DFR1115-868-Transmitter wiring diagram

  • Receiver (The connection method for both the first and second groups is as follows):

DFR1115-868-Receiver wiring diagram

Sample Code

Transmitter Program: Set node address to 1, send temperature and humidity sensor data to node with address 2.

#include <DFRobot_LWNode.h>
#include <dht11.h>
dht11 DHT;
#define DHT11_PIN 4
#define FREQ  868100000 
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, DBM16, 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);  // Get data from 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(2, DHT11_DATE);  // Send temperature and humidity data to node with address 2
    node.sleep(5000);
}

The first and second groups of receivers both use the following program (note: set different serial ports): set the node address to 2 to receive data from the node with address 1.

#include <DFRobot_LWNode.h>
#define FREQ  868100000 
DFRobot_LWNode_UART node(2); // Set node address to 2

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.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); // Note: Set different UART ports
    delay(5000);
    node.begin(/*communication UART*/&Serial1, /*debug UART*/&Serial);
    const uint32_t loraConfig[] = {FREQ, DBM16, 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 from the transmitter:

DFR1115-868-One-to-Many Communication result1

Serial output from the first group of receivers:

DFR1115-868-One-to-Many Communication result2

Serial output from the second group of receivers:

DFR1115-868-One-to-Many Communication result3

Was this article helpful?

TOP