• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Receiving incoming data from multiple LoRa sender

Q&A Forum › Receiving incoming data from multiple LoRa sender
0 Vote Up Vote Down
Nazmie Razali asked 6 years ago

Hi there, in my project, I need to use a Heltec WIFI Lora 32 as a receiver and three others as the Lora sender labelled 1,2 and 3, sending temperature and humidity data. Im using your module 11 as reference and edited some of the code according to my need, but it seems not work. So my question is;

  1. How to sort out the incoming data into specific variable based on the labelled lora sender? for example, temperature and humidity data from sender#2 will go into variable temperature2 and humidity2 respectively. 
  2. How can I determine the data is coming from which sender? because function Lora.readString() can grab any incoming Lora data right?

Hope you can help me, thank you.

6 Answers
0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

Hi.

To sort out the data and figure out where it came from, I suggest that you add some sort of identification to the message on the sender side.

For example, sender number 1 sends a message in the following format:

“1#Temperature/Humidity”

The message from sender 2:

“2#Temperature/Humidity”

Then, in the receiver side add an if statement to associate each measurement with the corresponding variable.
Something as we do in this code, lines 222 to 229: https://github.com/RuiSantosdotme/ESP32-Course/blob/master/code/LoRa_Project/LoRa_Receiver/LoRa_Receiver.ino

for example:

// checks if the message contains the "1#" characters
if senderID = LoRaData.indexOf(1#)>0{
  //this is data from sensor 1
  //save the data on corresponding variables
}

add some more if statements to identify the messages from other senders.

The LoRa.readString() method grabs any incoming data nomatter where it cames from, unless you set a syncword (this is more useful for a single receiver and sender).

In your case, you can try to use the strategy I’ve described, or you can take a look at the LoRaSimpleGateway and LoRaSimpleNode example on the library examples: https://github.com/sandeepmistry/arduino-LoRa/tree/master/examples

Please note, that I haven’t tested those examples, so I’m not sure if they will work for your scenario.
I hope this helps.

Regards,
Rui

0 Vote Up Vote Down
Nazmie Razali answered 6 years ago

Thanks for the idea, right now its work by using this code below:
senderID = LoRaData.substring(0, pos1);

if (senderID == “1”){
display.setCursor(0,0);
display.print(“SenderID: “);
display.setCursor(80,0);
display.print(senderID);
display.display();
temperature = LoRaData.substring(pos1+1, pos2);
humidity = LoRaData.substring(pos2+1, pos3);
batteryLevel = LoRaData.substring(pos3+1, LoRaData.length());

display.setCursor(0,8);
display.print(“Temperature: “);
display.setCursor(80,8);
display.print(temperature);
display.display();

display.setCursor(0,16);
display.print(“Humidity: “);
display.setCursor(80,16);
display.print(humidity);
display.display();
}

if (senderID == “2”){
display.setCursor(0,0);
display.print(“SenderID: “);
display.setCursor(80,0);
display.print(senderID);
display.display();
temperature_2 = LoRaData.substring(pos1+1, pos2);
humidity_2 = LoRaData.substring(pos2+1, pos3);
batteryLevel_2 = LoRaData.substring(pos3+1, LoRaData.length());
display.setCursor(0,8);
display.print(“Temperature: “);
display.setCursor(80,8);
display.print(temperature_2);
display.display();

display.setCursor(0,16);
display.print(“Humidity: “);
display.setCursor(80,16);
display.print(humidity_2);
display.display();
}
But there is a question in my head now, is it possible for both of them to receive the data at the same time? If so, am I gonna lose some information from a sender?

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

I don’t think so, LoRa can’t guarantee the message will receive the data… Only if you send an extra message to the sender to confirm the message. Sorry for taking so long to get back to you, but I was without internet for the last couple of days during a trip.

0 Vote Up Vote Down
delmarcodiego answered 6 years ago

You can also give a progressive number in a sender message, so you can know if you loose something.
Something like this :
1000000001+msg
1000000002+msg
and so on.. 

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

Yes, you can do that, but as you said it’s never guaranteed the message will be received and if you need 100% accuracy LoRa is not a good option-

0 Vote Up Vote Down
Nazmie Razali answered 6 years ago

thanks for the answer, very appreciate that 🙂

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.