Problems to send message from ESP32 Lora to another

flavioavilela
Posts: 4
Joined: Sun Jul 05, 2020 12:45 am

Problems to send message from ESP32 Lora to another

Postby flavioavilela » Tue Sep 22, 2020 10:43 pm

Hi.
I have three ESP32 with Lora network. I send a message from one EspLora1 to EspLora2 and it works properly. Now, I'm trying to get this data from EspLora2, make some treatments and send this new data to EspLora3. But, when I try this (EspLora2 to EspLora3), sometimes I get this data, but sometimes I does not get this data.

The codes is: In EspLora1, I send the message to LoRa network like this:

Code: Select all

	LoRa.beginPacket();
	LoRa.print("Some message here!!!");
	LoRa.endPacket();
At the same time, in the EspLora2, I try to read this message like this (inside loop code).

Code: Select all

	int packetSize = LoRa.parsePacket();
	if (packetSize > 0){
		while(LoRa.available()){
			received += (char) LoRa.read();
		}
		//Some codes here!!!
		//Some tratments here!!!
	}
Still in the EspLora2, after get the data from LoRa network, inside the "packetSize > 0" and after "while", if some condition is satisfy, I do like this code bellow to send this new message to LoRa network and consequently to EspLora3:

Code: Select all

	LoRa.beginPacket();
	LoRa.print("Another message here!!!");
	LoRa.endPacket();
At the same time, in the EspLora3, I do like this to read this another new message generated by EspLora2 (inside loop code):

Code: Select all

	int packetSize = LoRa.parsePacket();
	if (packetSize > 0){
		while(LoRa.available()){
			received += (char) LoRa.read();
		}
		//Another codes here!!!
		//Some others tratments here!!!
	}
In this moment, when I try to read the data that arrive in the EspLora3, I can read the data generated by EspLora1 perfectly (of course, the EspLora1 also generate data to LoRa network). But, I don't know why, the data generated by EspLora2, sometimes I could read, but sometimes I could'n read. It's very strange situation.

I noticed that to send message from EspLora2 to EspLora3, if I put the message into a string variable and to do

Code: Select all

"LoRa.print(variableWithMessage)"
it doesn't work at all. But also, if I put this message inside the code

Code: Select all

 "LoRa.write((unsigned char *)&"someMessageHere",sizeof("someMessageHere"))" 
it sometimes works (EspLora3 can read the message), but sometimes it doesn't work. Moreover, if I send a number (like a sequence count) from EspLora2 to EspLora3 it works perfectly. It's very very strange.

Can someone help me to manage to figure out this puzzle???

Who is online

Users browsing this forum: No registered users and 107 guests