[Maduino board] RFM95 LoRa init Issue

Hello everyone,

I request your help for my project since after searching everywhere on the internet I did not manage to find any solution for my problem. In a nutshell, I'm trying to implement a LoRa radio protocol between two "Maduino boards" from the manufacturer "Makerfabs".

![|500x375](https://www.makerfabs.com/image/cache/makerfabs/Maduino Lora Radio (868M)/Maduino Lora Radio (868M)_1-1000x750.JPG)

These board are basically arduino pro mini with an already wired up RFM95w LoRa radio module. I've recieved them a few days ago and immediately tried to test them with a basic example I've found on the boards wiki :

link

I've followed every steps very carefully and modified the example code to just send a test string between the two modules, and here came the problems. Here is my program :

// LoRa 9x_TX
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client (transmitter)
// with the RH_RF95 class. RH_RF95 class does not provide for addressing or
// reliability, so you should only use RH_RF95 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example LoRa9x_RX

//Function:Transmit DHT11 to Lora
//Author: Charlin
//Date:2019/12/11

#include <SPI.h>
#include "RH_RF95.h"

#define RFM95_CS 10
#define RFM95_RST 9
#define RFM95_INT 2

// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 868.0

// Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT);

void setup() 
{
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);

  
  while (!Serial);
  Serial.begin(9600);
  delay(100);

  Serial.println("Marduino LoRa TX Test!");

  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);

  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    while (1);
  }
  Serial.println("LoRa radio init OK!");

  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
  if (!rf95.setFrequency(RF95_FREQ)) {
    Serial.println("setFrequency failed");
    while (1);
  }
  Serial.print("Set Freq to: "); Serial.println(RF95_FREQ);
  
  // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on

  // The default transmitter power is 13dBm, using PA_BOOST.
  // If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then 
  // you can set transmitter powers from 5 to 23 dBm:
  rf95.setTxPower(23, false);

}

int16_t packetnum = 0;  // packet counter, we increment per xmission

void loop()
{

  String message = "#"+(String)packetnum+"test";
  Serial.println(message);
  packetnum++;
  Serial.println("Transmit: Sending to rf95_server");
  
  // Send a message to rf95_server

  uint8_t radioPacket[message.length()+1];
  message.toCharArray(radioPacket, message.length()+1);
  
  radioPacket[message.length()+1]= '\0';

  
  Serial.println("Sending..."); delay(10);
  rf95.send((uint8_t *)radioPacket, message.length()+1); 
  Serial.println("Waiting for packet to complete..."); delay(10);
  rf95.waitPacketSent();
  // Now wait for a reply
  uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  Serial.println("Waiting for reply..."); delay(10);
  if (rf95.waitAvailableTimeout(1000))
  { 
    // Should be a reply message for us now   
    if (rf95.recv(buf, &len))
   {
      Serial.print("Got reply: ");
      Serial.println((char*)buf);
      Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);    
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
  else
  {
    Serial.println("No reply, is there a listener around?");
  }
  delay(1000);
}

First, even before uploading the code to the board, I had a compiling issue basically saying :

exit status 1
no matching function for call to 'RH_RF95::RH_RF95(int, int)'

This seemed strange to me since every example code I've found out there used this typo. Anyway, after looking into the RH_RF95 library, I noticed that this constructor needed a software serial parameter. So I just change the begining of my code with :

#include <SPI.h>
#include <SoftwareSerial.h>
#include "RH_RF95.h"

#define RFM95_CS 10
#define RFM95_RST 9
#define RFM95_INT 2

// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 868.0

// Singleton instance of the radio driver
SoftwareSerial ss(RFM95_CS, RFM95_INT);
RH_RF95 rf95(ss);

Then, I was able to upload my program on the board without any problems. Unfortunately, a look at the serial monitor made me sad as the RFM95w module was not able to initialize itself, and my program returning :

09:37:40.493 -> Arduino LoRa TX Test!
09:37:46.535 -> 0
09:37:46.535 -> LoRa radio init failed

I then tried everything I could think of to make this module initialize itself :

  • I changed my program in every way possible by commenting some part of it
  • I modified the RFM95_CS and RFM95_INT pins
  • I checked the wiring on the board with a multimeter (everything was connected as expected and the 3.3V input was indeed at 3.3v)
  • I upload using different computers and cables
  • I checked my two Maduino boards to see if one of them was faulty, but I had the same problem on both
  • I upload programs I've found on Github, Youtube or Arduino from other peoples who had some init issues but none of them worked

Here's my final program :

// LoRa 9x_TX
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client (transmitter)
// with the RH_RF95 class. RH_RF95 class does not provide for addressing or
// reliability, so you should only use RH_RF95 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example LoRa9x_RX

//Function:Transmit DHT11 to Lora
//Author: Charlin
//Date:2019/12/11

#include <SPI.h>
#include <SoftwareSerial.h>
#include "RH_RF95.h"

#define RFM95_CS 10
#define RFM95_RST 9
#define RFM95_INT 2

// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 868.0

// Singleton instance of the radio driver
SoftwareSerial ss(RFM95_CS, RFM95_INT);
RH_RF95 rf95(ss);

void setup() 
{
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);

  
  while (!Serial);
  Serial.begin(9600);
  delay(100);

  Serial.println("Marduino LoRa TX Test!");

  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);

  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    while (1);
  }
  Serial.println("LoRa radio init OK!");

  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
  if (!rf95.setFrequency(RF95_FREQ)) {
    Serial.println("setFrequency failed");
    while (1);
  }
  Serial.print("Set Freq to: "); Serial.println(RF95_FREQ);
  
  // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on

  // The default transmitter power is 13dBm, using PA_BOOST.
  // If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then 
  // you can set transmitter powers from 5 to 23 dBm:
  rf95.setTxPower(23, false);

}

int16_t packetnum = 0;  // packet counter, we increment per xmission

void loop()
{

  String message = "#"+(String)packetnum+"test";
  Serial.println(message);
  packetnum++;
  Serial.println("Transmit: Sending to rf95_server");
  
  // Send a message to rf95_server

  uint8_t radioPacket[message.length()+1];
  message.toCharArray(radioPacket, message.length()+1);
  
  radioPacket[message.length()+1]= '\0';

  
  Serial.println("Sending..."); delay(10);
  rf95.send((uint8_t *)radioPacket, message.length()+1); 
  Serial.println("Waiting for packet to complete..."); delay(10);
  rf95.waitPacketSent();
  // Now wait for a reply
  uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  Serial.println("Waiting for reply..."); delay(10);
  if (rf95.waitAvailableTimeout(1000))
  { 
    // Should be a reply message for us now   
    if (rf95.recv(buf, &len))
   {
      Serial.print("Got reply: ");
      Serial.println((char*)buf);
      Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);    
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
  else
  {
    Serial.println("No reply, is there a listener around?");
  }
  delay(1000);
}

So now I'm basically out of ideas, so if any of you have had any issues like this one, I'd be very happy to hear about how you solved it !

jsjskat:
Anyway, after looking into the RH_RF95 library, I noticed that this constructor needed a software serial parameter.

Then, I was able to upload my program on the board without any problems. Unfortunately, a look at the serial monitor made me sad as the RFM95w module was not able to initialize itself, and my program returning :

No Idea why you think that the Radio head library needs software serial to make that SPI based LoRa device work, confusion with another board perhaps ?

The first program you posted (the one without all the software serial stuff) works the second one with the software serial stuff does not, as expected really.

I know that's strange to me too, but as I said, whenever I try to compile the code with this typo, I get this error :

Arduino: 1.8.12 (Windows 10), Board: "Arduino Pro or Pro Mini, ATmega328P (3.3V, 8 MHz)"

LoRa_send:24:33: error: no matching function for call to 'RH_RF95::RH_RF95(int, int)'

 RH_RF95 rf95(RFM95_CS, RFM95_INT);

                                 ^

In file included from C:\Users\NOSTROMO\Desktop\LoRa_send\LoRa_send.ino:14:0:

C:\Users\NOSTROMO\Documents\Arduino\libraries\Grove_-_LoRa_Radio_433MHz_868MHz/RH_RF95.h:238:5: note: candidate: RH_RF95::RH_RF95(SoftwareSerial&)

     RH_RF95(SoftwareSerial& ss);

     ^~~~~~~

C:\Users\NOSTROMO\Documents\Arduino\libraries\Grove_-_LoRa_Radio_433MHz_868MHz/RH_RF95.h:238:5: note:   candidate expects 1 argument, 2 provided

C:\Users\NOSTROMO\Documents\Arduino\libraries\Grove_-_LoRa_Radio_433MHz_868MHz/RH_RF95.h:206:7: note: candidate: constexpr RH_RF95::RH_RF95(const RH_RF95&)

 class RH_RF95 : public RHUartDriver

       ^~~~~~~

C:\Users\NOSTROMO\Documents\Arduino\libraries\Grove_-_LoRa_Radio_433MHz_868MHz/RH_RF95.h:206:7: note:   candidate expects 1 argument, 2 provided

C:\Users\NOSTROMO\Documents\Arduino\libraries\Grove_-_LoRa_Radio_433MHz_868MHz/RH_RF95.h:206:7: note: candidate: constexpr RH_RF95::RH_RF95(RH_RF95&&)

C:\Users\NOSTROMO\Documents\Arduino\libraries\Grove_-_LoRa_Radio_433MHz_868MHz/RH_RF95.h:206:7: note:   candidate expects 1 argument, 2 provided

Multiple libraries were found for "RH_RF95.h"
 Used: C:\Users\NOSTROMO\Documents\Arduino\libraries\Grove_-_LoRa_Radio_433MHz_868MHz
 Not used: C:\Users\NOSTROMO\Documents\Arduino\libraries\Reliable_datagram
exit status 1
no matching function for call to 'RH_RF95::RH_RF95(int, int)'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I tried to reinstall the library but it did not solve it

Your using the wrong library perhaps.

Try removing that Grove library and install the Radiohead one.

Ok I'm the worst not to have thought of this ahah ! you were right, the RadioHead Library works like a charm ! they should delete this grove library in order to avoid confusion.

Thank you very much :slight_smile:

jsjskat:
Ok I'm the worst not to have thought of this ahah ! you were right, the RadioHead Library works like a charm ! they should delete this grove library in order to avoid confusion.

Thank you very much :slight_smile:

One does wonder why Grove gave their library (for a UART fronted LoRa module) the same names as the well established Radiohead library.

And why Maduino assumed the Grove library was the right one to install for their 'tutorial'