arduino-LoRa icon indicating copy to clipboard operation
arduino-LoRa copied to clipboard

LoRa receiver not working

Open AnandhaLakshmanan opened this issue 3 years ago • 4 comments

I am using two LoRa sx1278 with arduino uno boards. the sender node is working perfectly but the receiver doesn't show any received messages. LoRa initialization is okay in both receiver and sender.

sender code : #include <SPI.h> #include <LoRa.h>

int counter = 0;

void setup() { Serial.begin(9600); while (!Serial);

Serial.println("LoRa Sender");

if (!LoRa.begin(433E6)) { Serial.println("Starting LoRa failed!"); while (1); } }

void loop() { Serial.print("Sending packet: "); Serial.println(counter);

// send packet LoRa.beginPacket(); LoRa.print("hello "); LoRa.print(counter); LoRa.endPacket();

counter++;

delay(5000); }

Receiver code : #include <SPI.h> #include <LoRa.h>

void setup() { Serial.begin(9600); while (!Serial);

Serial.println("LoRa Receiver");

if (!LoRa.begin(433E6)) { Serial.println("Starting LoRa failed!"); while (1); } }

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((char)LoRa.read());
}

// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi());

} }

AnandhaLakshmanan avatar May 06 '22 08:05 AnandhaLakshmanan

I once had the same problem, if your sender is not connected to a serial device (i.e. your PC) the line while (!Serial); will halt your program. If you remove that it should work.

marius-ne avatar May 11 '22 08:05 marius-ne

i did project with lora back then and everything is good, and i now i tried to use it again, i can't get any data from lora sender. i tried to change the arduino uno and the problem is the same. Is there any solution?

image

efraimwilliam avatar Nov 26 '22 06:11 efraimwilliam

You don't set SF, BW, CR parameters, so they could be different on both devices.

Kongduino avatar Nov 26 '22 09:11 Kongduino

You don't set SF, BW, CR parameters, so they could be different on both devices.

Thank you for your reply. If it's okay, can i have the example of what you meant by setting SF, BW, and CR parameters?

efraimwilliam avatar Dec 02 '22 10:12 efraimwilliam