Using LoRa with arduino nano

I have two simple setups, each containing an Arduino Nano and a LoRa SX1278 RA-02 module, with the aim of establishing half-duplex communication.



To test the hardware first, I uploaded a sender code to the first setup (which sends the message 'HELLO 1, HELLO 2, ...') and a receiver code to the second setup, as shown above.

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

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

However, when I display the results on the serial monitor, I find that the transmission setup works well, but the reception setup has issues:

   - It either displays nothing.

   - Or it displays strange characters, as shown in the screenshot.

I always encounter problems with reception. Has anyone else experienced these issues? How did you resolve them?

Does your LORA board have level shifters to cope with the 5v SPI signals from the Nano?

The LoRa device uses 3.3V logic level signals and the Nano uses 5V logic level signals which can damage the LoRa module if connected directly.

The Nano 3.3V supply might not provide enough current for the LoRa transmitter.

you appear to have missed the call to setpins(), e.g.

void setup() {
    Serial.begin(115200);
    while (!Serial);
    Serial.println("LoRa Sender ");
    //void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN);
    LoRa.setPins(10, 9, 2); // 10 for UNO and Nano, 53 for Mega
    if (!LoRa.begin(433E6)) {
      .......

Hi, @aitsalem
Welcome to the forum.

What baud rate do you have the IDE monitor set at?
I should be

9600 at the reciever.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

I have also set the baud rate of the IDE's serial monitor to 9600.

I conducted a search, but I did not find a clear answer according to its datasheet.The LoRa module I'm using is the SX1278 RA-02 433MHz.

looking at the receiver serial monitor output in post 1 you are receiving parts of transmitted messages then corrupted information
are there any other 433mhz devices in the area which could be corrupting transmissions?
how far apart are the RA-02 modules?
maybe worth printing the value of packetSize

@mikb55 - Are you sure that we need Level shifters for 3.3V ??
I ask this question because, in number of forums and Youtube videos, none of them recommend to use a Level shifter between Arduino Uno / Nano and Lora SX-1278 modules !!

For reference, you can follow one of the forum - https://how2electronics.com/interfacing-sx1278-lora-module-with-arduino/

If you have schematic / connection diagram with connections between Arduino Uno / Nano - LoRa SX-1278 - Level Shifter, please do share

Thanks,

Definitely, you can damage the LoRa module.

Connecting 5V logic level pins direct to the LoRa module can cause also cause phantom power feeding to the LoRa module and raise the VCC level to 4V, which exceeds the maximum Semtech specify. Read here;

https://stuartsprojects.github.io/2020/11/28/Do-not-connect-LoRa-devices-to-5V-Arduinos.html

@srnet Thanks for the response, the url link seems isn't working!! Could you please share connection diagram between arduino - level shifter - lora ?

Dont have one.

Been using LoRa modules since they were first released in 2014, never used a 5V logic level Arduino with them. I did maybe try once in 2015, but quickly gave up on the idea.

Lots of info out there on 'Arduino Logic Level Conversion'

Link works for me, maybe you have been caught up in the Microsoft moves to 'enhance security' on Github.

1 Like

on a device which uses 3.3V logic unless pins are specified as 5volt tolerant the device can be damaged if 5V logic is applied
in practice 3.3V devices may work with 5V logic for an minute, an hour, a day, for ever or fail immediately - you don't know - use level converters or even better switch to a microcontroller which uses 3.3V logic
this applies not only to LoRa modules but other WiFi modules, displays, sensors, etc

@horace I'm connecting the LoRa module 3.3V pin with Arduino's 3.3V pin (and not to 5V pin), then we does the LoRa module receive 5V supply ??

even if you power the RA-02 from 3.3V if you are using a 5V logic device (e.g. UNO, classic Nano, etc) any output signal (e.g. MOSI, SCLK, CS) which you input to the RA--02 will be at 5Volts and may damage the 3.3V logic RA-02

1 Like