Arduino Uno + LoRa RFM95W sending/receiving issue

Hello,

I'm having trouble getting RFM95W to work with Arduino Uno and my problems are the following :

  • On the sender setup, sending packets stop at 0, 1 or 2 (LoraSender example, Image1).


    I tried to measure the input voltage of the RFM95W during transmission and it was stable at 3.27V. Strangely, when I measured the voltage, the sending packet didn't stop at 0, 1 or 2 and kept going until I removed the probes of my multimeter from the RFM95W (Image2).

  • On the receiver setup, there were 3 cases:

  1. Nothing happens, serial monitor stays clear.
  2. I'm receiving the packet with very low RSSI (-157) (first line of Image3).
  3. I'm receiving the packet with low RSSI (-109) and the message keeps spamming in the serial monitor (Image3).
    Image3

I have the following setup for both sender and receiver :

  • Arduino Uno board with screw shield
  • Buck converter (5V to 3.3V to power the RFM95W) connected to Arduino 5v output and RFM95W 3.3v input
  • 8 channel 5V/3.3V bidirectionnal logic level converter
  • RFM95W

A scheme and a picture of the setup are given in the message below (sorry I'm a new user, I can't post more than 3 media at a time). Antenna in the scheme is not representative of my real antenna, which is a helical antenna as you can see on the picture. I forgot to put a ground cable between the buck converter and the RFM95W in the scheme but it is present in the real setup

Each RF95W are connected to Arduino Uno following sandeepmistry instructions (GitHub - sandeepmistry/arduino-LoRa: An Arduino library for sending and receiving data using LoRa radios.) (I'm using his LoRa library) :

RFM95W Arduino Uno
VCC 3.3V (from buck converter)
GND GND (from buck converter)
SCK D13
MISO D12
MOSI D11
NSS D10
NRESET D9
DIO0 D2

And I'm using the examples of Sender and Receiver supplied by sandeepmistry , where I've only changed the frequency (868 MHz instead of 915 MHz).

Sender :

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

int counter = 0;

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

  Serial.println("LoRa Sender");

  if (!LoRa.begin(868E6)) {
    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);
}

Receiver :

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

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

  Serial.println("LoRa Receiver");

  if (!LoRa.begin(868E6)) {
    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());
  }
}

I don't understand why the sending setup is working when I'm putting the multimeter probes to 3.3V and GDN pins of the RFM95W. And why is the RSSI so low while both setups are 1 meter apart.


What are you measuring it with. Post an annotated schematic showing what you have connected together, be sure to show power sources and note any lead over 10"/25cm. Your screen shots are not readable. Post links to technical information on each of the hardware items.

I measured it with a multimeter on 3.3V and GND pins of the RFM95W.

I posted a schematic below my first message (sorry I'm a new user, I cannot post more than 3 images at a time).

There are no cable over 20 cm, I measured them.

You mean the screenshots from serial monitor ? It's weird, they are really clear when I click on them.

Here are links to technical information of each of the hardware items :
HopeRF RFM95W: https://cdn.sparkfun.com/assets/a/e/7/e/b/RFM95_96_97_98W.pdf
8 channel 5V/3.3V bidirectionnal logic level converter: https://www.ti.com/lit/ds/symlink/txs0108e.pdf?ts=1719719191343&ref_url=https%253A%252F%252Fti.com%252Flit%252Fgpn%252FTXS0108E
I couldn't find a datasheet for the buck converter since it's a generic module I bought on Aliexpress : https://www.aliexpress.com/item/33052121533.html?spm=a2g0o.order_list.order_list_main.29.6e821802jki9NR

if I run your sender on an Adafruit Feather 32u4 LoRa it displays

LoRa Sender
Sending packet: 0
Sending packet: 1
Sending packet: 2
Sending packet: 3
Sending packet: 4
Sending packet: 5
Sending packet: 6
Sending packet: 7
Sending packet: 8
Sending packet: 9
Sending packet: 10
Sending packet: 11
Sending packet: 12
Sending packet: 13
Sending packet: 14
Sending packet: 15

the Adafruit Feather 32u4 LoRa receiver displays

LoRa Receiver
Received packet 'hello 0' with RSSI -77
Received packet 'hello 1' with RSSI -77
Received packet 'hello 2' with RSSI -77
Received packet 'hello 3' with RSSI -77
Received packet 'hello 4' with RSSI -77
Received packet 'hello 5' with RSSI -77
Received packet 'hello 6' with RSSI -77
Received packet 'hello 7' with RSSI -77
Received packet 'hello 8' with RSSI -76
Received packet 'hello 9' with RSSI -77
Received packet 'hello 10' with RSSI -74
Received packet 'hello 11' with RSSI -73
Received packet 'hello 12' with RSSI -72
Received packet 'hello 13' with RSSI -73
Received packet 'hello 14' with RSSI -73
Received packet 'hello 15' with RSSI -73
Received packet 'hello 16' with RSSI -74
Received packet 'hello 17' with RSSI -73
Received packet 'hello 18' with RSSI -73
Received packet 'hello 19' with RSSI -73
Received packet 'hello 20' with RSSI -73

the only modification to your code was to call setpins() with the pin setting for the Feather 32u4

  LoRa.setPins(8,4,7);   // for Lora 32u4
  if (!LoRa.begin(868E6)) {

looks like you have a hardware problem

1 Like

It would seem so, but I don't understand what the problem is. I've even checked the continuity of all the wires and solder joints : everything is fine and there are no short circuits.

What I don't understand is that when I'm putting the multimeter probes to 3.3V and GDN pins of the RFM95W, the sending setup is working.

try running this program and see what registers are displayed

/*******************************************************************************************************
  Program Operation - This program is stand alone, it is not necessary to install a LoRa library to use
  it. This test program is for the SX127X LoRa devices.

  The program checks that a LoRa device can be accessed by doing a test register write and read.
  If there is no device found a message is printed on the serial monitor. The contents of the registers
  from 0x00 to 0x0F are then printed.

  The Arduino pin number that NSS on the LoRa device is connected to must be specified in #define NSS
  line below. The DIO0 pin is not needed and you can leave the NRESET not connected as well.

  Typical printout;

  85_SX127X_LoRa_Device_Check Starting
  LoRa Device found
  Device version 0x12
  Frequency 434000000

  Registers 
  Reg    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
  0x00  00 09 1A 0B 00 52 6C 80 00 4F 09 2B 20 08 02 0A 

  Note: An SX1272 will report as version 0x22 and the frequency at power up is 915000000hz.

  ESP32
  -----
  For an ESP32 microcontroller you can specify the SCK, MOSI and MOSI pins used by the SPI interface by
  adding these defines;

  #define SCK 18
  #define MISO 19
  #define MOSI 23

  Then begin the SPI interface like this;

  SPI.begin(SCK, MISO, MOSI);


  Serial monitor baud rate is set at 115200.
*******************************************************************************************************/

const uint8_t REG_FRMSB = 0x06;                 //register number for setting and reading frequency, high byte
const uint8_t REG_FRMID = 0x07;                 //register number for setting and reading frequency, mid byte
const uint8_t REG_FRLSB = 0x08;                 //register number for setting and reading frequency, low byte
const uint8_t REG_VERSION = 0x42;               //register containg version number of device


//*********  Setup hardware pin definition here ! **************
//#define NSS 8       // Feather 32u4
//#define NRESET 4
#define NSS 10        // UNO drango shield
#define NRESET 9      // UNO drango shield                     

#define SCK 18                                  //for ESP32
#define MISO 19                                 //for ESP32
#define MOSI 23                                 //for ESP32  
//**************************************************************/

#include <SPI.h>

uint32_t frequency;


void setup()
{
  delay(2000);
  Serial.begin(115200);
  Serial.println(F("85_SX127X_LoRa_Device_Check Starting"));

  SPI.begin();//SCK, MISO, MOSI);                  //for ESP32
  
  SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));

  //The begin function setups the hardware pins used by device and then checks if device is found
  if (begin(NSS, NRESET))
  {
    Serial.println(F("LoRa Device found"));
  }
  else
  {
    Serial.println(F("No device responding"));
  }

  Serial.print(F("Device version 0x"));
  uint8_t deviceversion = readRegister(REG_VERSION);
  
  if (deviceversion < 0x10)
  {
    Serial.print(F("0"));
  }
  Serial.println(deviceversion, HEX);

  frequency = getFreqInt();                    //read the default set frequency following a powerup
  Serial.print(F("Frequency "));
  Serial.println(frequency);
  Serial.println();
  Serial.println(F("Registers "));             //show registers
  printRegisters(0x00, 0x0F);
}


void loop()
{
}


uint8_t readRegister(uint8_t address)
{
  uint8_t regdata;
  digitalWrite(NSS, LOW);                    //set NSS low
  SPI.transfer(address & 0x7F);              //mask address for read
  regdata = SPI.transfer(0);                 //read the byte
  digitalWrite(NSS, HIGH);                   //set NSS high
  return regdata;
}


void writeRegister(uint8_t address, uint8_t value)
{
  digitalWrite(NSS, LOW);                    //set NSS low
  SPI.transfer(address | 0x80);              //mask address for write
  SPI.transfer(value);                       //write the byte
  digitalWrite(NSS, HIGH);                   //set NSS high
}


void printRegisters(uint16_t Start, uint16_t End)
{
  //prints the contents of lora device registers to serial monitor
  uint16_t Loopv1, Loopv2, RegData;

  Serial.print(F("Reg    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F"));
  Serial.println();

  for (Loopv1 = Start; Loopv1 <= End;)
  {
    Serial.print(F("0x"));
    if (Loopv1 < 0x10)
    {
      Serial.print(F("0"));
    }
    Serial.print((Loopv1), HEX);
    Serial.print(F("  "));
    for (Loopv2 = 0; Loopv2 <= 15; Loopv2++)
    {
      RegData = readRegister(Loopv1);
      if (RegData < 0x10)
      {
        Serial.print(F("0"));
      }
      Serial.print(RegData, HEX);
      Serial.print(F(" "));
      Loopv1++;
    }
    Serial.println();
  }
}


bool begin(int8_t pinNSS, int8_t pinNRESET)
{
  pinMode(pinNSS, OUTPUT);
  digitalWrite(pinNSS, HIGH);

  pinMode(pinNRESET, OUTPUT);
  digitalWrite(pinNRESET, HIGH);
  delay(10);
  digitalWrite(pinNRESET, LOW);
  delay(10);
  digitalWrite(pinNRESET, HIGH);

  if (checkDevice())
  {
    return true;
  }

  return false;
}


bool checkDevice()
{
  //check there is a device out there, writes a register and reads back
  uint8_t Regdata1, Regdata2;
  Regdata1 = readRegister(REG_FRMID);               //low byte of frequency setting
  writeRegister(REG_FRMID, (Regdata1 + 1));
  Regdata2 = readRegister(REG_FRMID);               //read changed value back
  writeRegister(REG_FRMID, Regdata1);               //restore register to original value

  if (Regdata2 == (Regdata1 + 1))
  {
    return true;
  }
  else
  {
    return false;
  }
}


uint32_t getFreqInt()
{
  //get the current set LoRa device frequency, return as long integer
  uint8_t Msb, Mid, Lsb;
  uint32_t uinttemp;
  float floattemp;
  Msb = readRegister(REG_FRMSB);
  Mid = readRegister(REG_FRMID);
  Lsb = readRegister(REG_FRLSB);
  floattemp = ((Msb * 0x10000ul) + (Mid * 0x100ul) + Lsb);
  floattemp = ((floattemp * 61.03515625) / 1000000ul);
  uinttemp = (uint32_t)(floattemp * 1000000);
  return uinttemp;
}

my Dragino LoRa shield on a UNO displays

85_SX127X_LoRa_Device_Check Starting
LoRa Device found
Device version 0x12
Frequency 434000000

Registers 
Reg    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
0x00  00 09 1A 0B 00 52 6C 80 00 4F 09 2B 20 08 02 0A 

EDIT: the Dragino LoRa shield on a UNO running your receiver of post 1 displays

Received packet 'hello 319' with RSSI -29
Received packet 'hello 320' with RSSI -41
Received packet 'hello 321' with RSSI -31
Received packet 'hello 322' with RSSI -30
Received packet 'hello 323' with RSSI -30
Received packet 'hello 324' with RSSI -30
Received packet 'hello 325' with RSSI -30
Received packet 'hello 326' with RSSI -30
Received packet 'hello 327' with RSSI -31
Received packet 'hello 328' with RSSI -30

Looking at your frizzy (it is not a schematic) it appears you are powering the radio with the Arduino, it is not a power supply and the RF module will draw more current instantaneously then the Arduino can supply. Try an external 3V3 power supply. There are many kluges posted such as adding a capacitor, this are iffy at best. This may help you.
Gil's Crispy Critter Rules, they apply to processor hardware:
Rule #1. A Power Supply the Arduino is NOT!
Rule #2. Never Connect Anything Inductive (motor, speaker) to an Arduino!
Rule #3 Don't connecting or disconnecting wires with power on.
Rule #4 Do not apply power to any pin unless you know what you are doing.
Rule #5 Do not exceed maximum Voltages.
Rule #6 Many will not power a transmitter.
LaryD's Corollary's
Coro #1 when first starting out, add a 220R resistor in series with both Input and Output pins.
Coro #2 buy a DMM (Digital Multi-meter) to measure voltages, currents and resistance. Violating these rules tends to make crispy critters out of Arduinos.
Hint: It is best to keep the wires under 25cm/10" for good performance.