Hello there. I hope i am right here. I dont use this forum very often.
Yesturday i received my LoRa modules and instandly started testing it.
In general they´re working great with the example scetches ( basic sender and receiver ) but i have a small
problem in receiving the correct data. If i try to put an if- statement the whole code crashes and delivers wrong data.
Now to the code.
The sender does just sending numbers from 1 up to 16 and start again from 1.
My goal was, to do different actions if certain numbers appear. The modifyed receiver looks like this.
void loop() {
int packetSize = LoRa.parsePacket();
if (packetSize) {
Serial.print("Received packet '");
while (LoRa.available()) {
Serial.print((char)LoRa.read());
value = (char)LoRa.read(); // modification
}
// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi());
Serial.println(value); // modification
}
}
I just took the example code and tryed to modify it to my wishes. If i remove the marked lines the console output looks like this :
LoRa Receiver
Received packet '1' with RSSI -88
Received packet '5' with RSSI -97
Received packet '11' with RSSI -96
With my modifications it looks like this :
LoRa Receiver
Received packet '1' with RSSI -88
⸮
Received packet '5' with RSSI -97
⸮
Received packet '1' with RSSI -96
1
My question is, why do i get this curious values. I already tryed different datatypes and methods to convert the incoming data into another datatype but everytime i do so i get something like this out.
Does anyone have experience with this type of LoRa of experience with the LoRa library ?
If you need some more information please ask. I written everything down what i thought it could be useful.
void loop() {
// try to parse packet
int packetSize = LoRa.parsePacket();
if (packetSize) {
// received a packet
Serial.print("Received packet '");
// read packet
while (LoRa.available()) {
Serial.print((int)LoRa.read());
}
// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi());
}
}
a run using a couple of 32u4 Lora boards gives
Received packet '0' with RSSI -60
Received packet '1' with RSSI -20
Received packet '2' with RSSI -20
Received packet '3' with RSSI -20
Received packet '4' with RSSI -20
Received packet '5' with RSSI -20
Received packet '6' with RSSI -20
Received packet '7' with RSSI -20
Received packet '8' with RSSI -20
Received packet '9' with RSSI -20
Received packet '10' with RSSI -21
Received packet '11' with RSSI -21
Received packet '12' with RSSI -21
Received packet '13' with RSSI -21
Received packet '14' with RSSI -21
Received packet '15' with RSSI -60
Received packet '16' with RSSI -20
Received packet '1' with RSSI -20
Received packet '2' with RSSI -21
Received packet '3' with RSSI -20
Received packet '4' with RSSI -21
Thank you. I think it work now. With changing LoRa.print to write and deleting the first console print out it works find. i finally get some good results. Thank you very much.