sandeepmistry / arduino-LoRa

An Arduino library for sending and receiving data using LoRa radios.
MIT License
1.6k stars 621 forks source link

LoRa Gateway on EPS32 #639

Closed pyrotechnik closed 1 year ago

pyrotechnik commented 1 year ago

Hello, I'm trying to create a LoRa gateway that's always in receive mode. When it receives a message, it processes the data and then responds to the sensor and goes back into receiver mode. The problem is that if I use LoRaDuplexCallback.ino. I get an error immediately after receiving the message: Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

When I try LoRaReceiver.ino. Then I receive the data and process it. But when I try to reply nothing happens. The other side doesn't respond. If I load LoRaSender.ino into ESP. The sensor receives the data without a problem.

My code looks like this:


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

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

  Serial.println("LoRa Receiver");

  LoRa.setPins(LoRa_SS, LoRa_RST, LoRa_DI0);

  if (!LoRa.begin(433500000)) {
    Serial.println("LoRa init failed. Check your connections.");
  }

  LoRa.setSyncWord(0x39);
  LoRa.setSpreadingFactor(7);
  LoRa.setSignalBandwidth(250E3);
  LoRa.setCodingRate4(5);

}

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());

    LoRa.beginPacket();
    LoRa.print("hello ");
    LoRa.endPacket();
    delay(200);
  }
}

And I don't know what to try anymore. I would be glad for any advice or ideas.