LoRa modules: how to test if these are working?

So I took the plunge and tinker with LoRa.
Got 5 Lora RA-02 modules... and connected these to Arduino Pro Minis to run all at 3.3 V.

I installed the LoRa libraries, use the sender and receiver sketch and expected this to work, but it doesn't.

The connections:
// LoRa-02 SX1278 module PINs:
// 3.3 V and ground
// 9 = RST
// 10 = NSS
// 11 = MOSI
// 12 = MISO
// 13 = SCK
// LORA_DEFAULT_SPI_FREQUENCY 8E6
// LORA_DEFAULT_SS_PIN 10
// LORA_DEFAULT_RESET_PIN 9
// LORA_DEFAULT_DIO0_PIN 2

Now while writing this post, I looked at the enclosed cover for the chip and it says ISM:410-526 MHz. This may sound silly, but this lets me believe this module cannot send/receive at 915 MHz, which is the setting in my example programs.

Well, I changed LoRa.begin(433E6); ... however, no luck either.

How can I test, whether the 'sender' is actually sending?

This is my slightly modified code allowing me to use one file, while changing only one constant: bool B_IS_LORA_TRANCEIVER_ROLE_SENDER {false}; here for being a receiver.

/*
    SX1278 LoRa Module Ai-Thinker
*/
#include <Arduino.h>
#include <SPI.h>
#include <LoRa.h>

const uint32_t G_BAUD_RATE_HW {57600};          // hardware serial baud rate

bool B_IS_LORA_TRANCEIVER_ROLE_SENDER {false};


void sender()
{
    static int counter {0};

    // wait until the radio is ready to send a packet
    while (0 == LoRa.beginPacket())
    {
        Serial.print(F("Waiting for radio ..."));
        delay(100);
    }

    Serial.print(F("Sending packet: "));
    Serial.println(counter);

    LoRa.beginPacket();
    LoRa.print(F("Hello: "));
    LoRa.print(counter);
    // true = async / non-blocking mode
    //LoRa.endPacket(true);
    LoRa.endPacket();

    counter++;

    return;

}

// code for receiving
void receiver()
{
    // try to parse packet
    int packetSize = LoRa.parsePacket();

    if (true == packetSize)
    {
        // received a packet
        Serial.print(F("Received packet '"));

        // read packet
        while (LoRa.available())
        {
            Serial.print((char)LoRa.read());
        }

        // print RSSI of packet
        Serial.print(F("' with RSSI "));
        Serial.println(LoRa.packetRssi());
    }
    else
    {
        Serial.println(F("No packet received :("));
        delay(5000);
    }
}


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

    if (true == B_IS_LORA_TRANCEIVER_ROLE_SENDER)
    {
        Serial.println(F("LoRa Sender..."));
    }
    else
    {
        Serial.println(F("LoRa Receiver..."));
    }

    if (false == LoRa.begin(433E6))             // fit for AU 915E6
    {
        Serial.println(F("Starting LoRa failed!"));
        while (1);
    }
}


void loop()
{
    if (true == B_IS_LORA_TRANCEIVER_ROLE_SENDER)
    {
        sender();
        delay(5000);
    }
    else
    {
        receiver();
    }
}

Any hints appreciated.

I think you are on the right track, but 410-526 seems too wide. Can you provide a link to the web site you purchased the modules at?

You might try following this tutorial: Interfacing SX1278 (Ra-02) LoRa Module with Arduino – Circuit Schools

https://vi.aliexpress.com/item/1005006527420659.html
Re-reading the link, it says 433 (duh) :slight_smile:

It is exactly the same compared to what I am doing, except, I send an incrementing int and do serial.print() for the output instead of Poti in and LED out.

I wonder if there is a signal on one of the pins of the RA-02 that indicates it is doing something.

Radio waves being emitted by the antenna is a sure sign of proper function.

It is exactly the same compared to what I am doing

Actually, it is not. There are rather strange constructions in your code, for example this:

    // wait until the radio is ready to send a packet
    while (0 == LoRa.beginPacket())

Here, you attempt to parse a packet that has not been received:

    int packetSize = LoRa.parsePacket();

I strongly recommend to start with a working example.

3 Likes

You either need a known working LoRa receiver or something like an SDR which will give you a visual indication of a transmitted packet.

You can set up the LoRa device so that for instance, DIO0, goes high when a packet has finished transmission or one has been received.

But by default the library you are using does not do this.

1 Like

LoRa RF Library use the DI0 pin.

Get something working first then modify it.

1 Like

:slight_smile: Funny... My index finger is not tuned to 433 MHz...

Thank you; you are quite right...

I simply ditched my program installed the transmitter and receiver script as per your link and it now works. Same thing though, changed poti and LED for Serial.print() statements.

What I noticed though, while I am sending every 5 seconds the incremented number, the receiver prints it countless times.
The fix is to bring Serial.println(val); into the if (packetSize).

Awesome! :slight_smile:

Received: 142 with RSSI: -93
Received: 143 with RSSI: -93
Received: 144 with RSSI: -94
Received: 145 with RSSI: -93
Received: 146 with RSSI: -93
Received: 147 with RSSI: -93
Received: 148 with RSSI: -93

The code posted suggests that the Sandeep LoRa library is in use;

https://github.com/sandeepmistry/arduino-LoRa?tab=readme-ov-file

By default DIO0 is not used to indicates packet complete. It can however be used for the non-blocking interrupt callback functions.

To detect packet complete the library reads a register on the LoRa device until the packet complete flag is set.

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