Search code examples
arduinofreezelora

Arduino Nano with RA-02(SX1278) Freezes after receiving


I got two identical Arduino Nano clones (CH340s) with RA-02 LoRa modules from the same place. I am using the LoRaReceiver and LoRaSender sketches from Esplora library (just changed the frequency to 433)

Receiver: '''

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

'''

Sender: '''

#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);
}

'''

Connected as

Link to the website with the image

Note that the potentiometer was not used. And it is receiving a random amount of messages before dying. It still draws current so the module must be working (TX around 5mA idle and 130mA on transmit, while RX is around 5mA always). The modules are supplied with power through 2x (3.3V DC2DC 100mA modules) each, with total of 200mA per RA-02. The supply for those DC2DC is taken from the 5V of the arduino which is connected through USB to my desktop.

After restart (changing the bandwidth of the monitor and setting it back to 9600) it starts receiving again fro a really short period of time. Average of around 7 messages before freezeing again.


Solution

  • After a lot of testing last week with one of my friends we decided to try a bigger board for receiving, since the sending is not stalling. He suggested Arduino Mega but since I had a 4GB RPi laying on my desk we decide to hook it up.

    There is no issue with it, so if anyone have this kind of issue I'd suggest to try the templates (so you will leave plenty of free space) and if possible use bigger board.

    The PI is receiving for around an hour with no issue.

    If using PI I'd also use htop to see if there are any issues with the memory : ]

    Oh and the setup guide I used: https://circuitdigest.com/microcontroller-projects/raspberry-pi-with-lora-peer-to-peer-communication-with-arduino

    I just need to install pip3 with sudo apt-get install python3-pip or sudo apt-get install python-pip (I used python3). Everything else is 'as is' in the guide.