LoRa Receiver stops receiving packets when LoRa Sender gets restarted

I have created a LoRa sender node and a receiver.

When I power up both sender and receiver at a time, the receiver started receiving packets and serial monitor prints the received data as expected.

But when I switch off the sender node and switch it on after few seconds, no received data is shown in Serial Monitor. Communication is happening again normally, when I press reset button of the Receiver. Please correct me if anything is wrong and suggest a solution to address this issue.

HW Used:

Sender Node: ESP32-WROOM-32 (ESP32-DevKitC) and SX1278(Ra-02) LoRa module with spring type antenna

Receiver: ESP32-WROOM-32 (ESP32-DevKitC) and SX1278(Ra-02) LoRa module with spring type antenna

Code: Sender

#include <SPI.h>
#include <LoRa.h>
#include <Wire.h> 

//define the pins used by the transceiver module
#define ss 5
#define rst 14
#define dio0 2

int counter = 0;

void setup() {
  //initialize Serial Monitor
  Serial.begin(115200);

  while (!Serial);

  Serial.println("LoRa Sender");

  LoRa.setPins(ss, rst, dio0);

  while (!LoRa.begin(433E6)) {
    Serial.println(".");
    delay(500);
  }

  LoRa.setSyncWord(0xF3);
  Serial.println("LoRa Initializing OK!");
}

void loop() {

 sendpacket();
 delay(2000);
}


void sendpacket()
{
  Serial.print("Sending packet: ");
  Serial.println(counter);
  //Send LoRa packet to receiver
  LoRa.beginPacket();
  LoRa.print("hello ");
  LoRa.print(counter);
  LoRa.endPacket();
  counter++;
  delay(5000);
}

Code: Receiver

#include <SPI.h>
#include <LoRa.h>

//define the pins used by the transceiver module
#define ss 5
#define rst 14
#define dio0 2

void setup() {

  //initialize Serial Monitor
  Serial.begin(115200);

  while (!Serial);
  Serial.println("LoRa Receiver");

  LoRa.setPins(ss, rst, dio0);

  while (!LoRa.begin(433E6)) {
    Serial.println(".");
    delay(500);
  }

  LoRa.setSyncWord(0xF3);
  Serial.println("LoRa Initializing OK!");

  // register the receive callback
  LoRa.onReceive(onReceive);

  // put the radio into receive mode
  LoRa.receive();

}

void loop() {  }

void onReceive(int packetSize) {
  // received a packet
  Serial.print("Received packet '");

  // read packet
  for (int i = 0; i < packetSize; i++) {
    Serial.print((char)LoRa.read());
  }

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

Are you using the exact same code as above ?

If your not you should start your own topic and post the code and connections you are using and also describe the problem in full.

yes same code

So why are you trying to use a bit of code that someone says does not work properly ?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.