LoRa FANET with RH_RF95.h and RFM95W

Hello, I am making some experiment to work with FANET+ network. I would like to publish wind data from a Photon connected anemometer to the FANET network (is a LoRa application for paragliding devices).

I have two devices working on this network (they are talking togheter) and I would like to add a custom Photon with RFM95W transceiver.

This is the FANET specification:

868.2Mhz
Syncword 0xF1
250kHz Bandwidth
Spreading Factor 7
ExplicitHeader: Coding Rate CR 5-8/8 (depending on #neighbors), CRC for Payload

This my code, it compile, it runs (no error on RF95 init) but I can’t see any raw data.

// This #include statement was automatically added by the Particle IDE.
#include <RH_RF95.h>
     
#include <SPI.h>
 
#define RFM95_RST     1  
#define RFM95_CS      6
#define RFM95_INT     2   

#define SERIAL_DEBUG

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

#define LED 7
SYSTEM_THREAD(ENABLED);
 
void setup()
{
  delay(5000);    
    
  pinMode(LED, OUTPUT);
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);
 
  Serial.begin(115200);
  while (!Serial) {
    delay(1);
  }
  delay(100);
 
  Serial.println("Feather LoRa RX Test!");
 
  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);
 
  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    Serial.println("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info");
    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);
 
  rf95.setSignalBandwidth(250E3);
  rf95.setSpreadingFactor(7);
  rf95.setCodingRate4(8);
  rf95.setPreambleLength(12);
  rf95.setPayloadCRC(1);
  // 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);
}
 
void loop()
{
  if (rf95.available())
  {
    // Should be a message for us now
    uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
 
    if (rf95.recv(buf, &len))
    {
      digitalWrite(LED, HIGH);
      RH_RF95::printBuffer("Received: ", buf, len);
      Serial.print("Got: ");
      Serial.println((char*)buf);
       Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);
 
      // Send a reply
      uint8_t data[] = "And hello back to you";
      rf95.send(data, sizeof(data));
      rf95.waitPacketSent();
      Serial.println("Sent a reply");
      digitalWrite(LED, LOW);
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
}

Where I am wrong? How can I deal with it?

@not103 ,
Did you
-define RF95_FREQ somewhere’s?
-double check wiring?

FREQ was defined, after paste the code I probbly accidentally delete it with an unnecessary comment.

Just after #define LED 7 there is

#define RF95_FREQ 868.2

Wiring seems ok. Same RFM95W board connected to an ESP8266 works, it connect with the above LoRa implementation.

This is a printout of RFM95W registry:

1: 81
6: D9
7: 0
8: 0
9: 88
A: 9
B: 2B
C: 20
D: 0
E: 0
F: 0
10: 0
11: 0
12: 0
13: 0
14: 0
15: 0
16: 0
17: 0
18: 10
19: 0
1A: 0
1B: 0
1C: 0
1D: 88
1E: 74
1F: 64
20: 0
21: 8
22: 1
23: FF
24: 0
25: 0
26: 4
27: 0
39: F1
42: 12

@not103
hmmm, can't see any other problems...
However, I have been using

sendtoWait

(RHReliableDiagram) successfully rather than your use of

  rf95.send(data, sizeof(data));
  rf95.waitPacketSent();

You might look at my gists at bprobbins’s gists · GitHub

Well I would like to start trying to receive a message (the two devices sends broadcast message) but I can’t get anything.

I'd start by trying the default modem settings:

rf95.setModemConfig(RH_RF95::Bw125Cr45Sf128 );

on two devices, then if that works try out your earlier setting one by one.
I actually never could successfully get anything but the default settings to work

The devices I have aren’t customizable, they only works with configuration with these specs:

868.2Mhz
Syncword 0xF1
250kHz Bandwidth
Spreading Factor 7
ExplicitHeader: Coding Rate CR 5-8/8 (depending on #neighbors), CRC for Payload

I think the recommended library to use is RF9X-RK. Did you try that?

@not103
Not sure what specific thing did it, but with a few changes, it works for me:
First, added the RF9X-RK library as above.
Second, I apparently wired the feather radio differently, so changed those defines - see code below:
Third, eliminated the initial delay - caused panic in my photons for some reason, and it’s unnecessary.
Fourth, set up a random seed to provide a random delay in loop so that the two devices don’t get in a race issue or sync lock.
Fifth, put a startup message at the end of setup in one device.
I also reduced txpower since I had my two photons side by side
Photon1:

// This #include statement was automatically added by the Particle IDE.
#include <RF9X-RK.h>


// This #include statement was automatically added by the Particle IDE.
#include <RH_RF95.h>
     
#include <SPI.h>
/* 
#define RFM95_RST     1  
#define RFM95_CS      6
#define RFM95_INT     2  
*/ 
#define RFM95_CS  A2 
#define RFM95_RST 4 
#define RFM95_INT D2 

#define SERIAL_DEBUG

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

#define LED 7
SYSTEM_THREAD(ENABLED);
 
 #define RF95_FREQ 915.0
 
void setup()
{
 // delay(5000);    
    
  pinMode(LED, OUTPUT);
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);
 
  Serial.begin(115200);
  while (!Serial) {
    delay(1);
  }
  delay(100);
 
  Serial.println("Feather LoRa RX Test!");
 
  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);
 
  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    Serial.println("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info");
    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);
 
  rf95.setSignalBandwidth(250E3);
  rf95.setSpreadingFactor(7);
  rf95.setCodingRate4(8);
  rf95.setPreambleLength(12);
  rf95.setPayloadCRC(1);
  // 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(6, false);
  
    randomSeed(analogRead(0));  

    uint8_t data2[] = "Start Message";
    rf95.send(data2, sizeof(data2));
    rf95.waitPacketSent();
}
 
void loop()
{
  if (rf95.available())
  {
    // Should be a message for us now
    uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
 
    if (rf95.recv(buf, &len))
    {
      digitalWrite(LED, HIGH);
      RH_RF95::printBuffer("Received: ", buf, len);
      Serial.print("Got: ");
      Serial.println((char*)buf);
       Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);

 delay(random(1000, 2000));
 
      // Send a reply
      uint8_t data[] = "And hello back to you";
      rf95.send(data, sizeof(data));
      rf95.waitPacketSent();
      Serial.println("Sent a reply");
      digitalWrite(LED, LOW);
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
}

And Photon 2:

// This #include statement was automatically added by the Particle IDE.
#include <RF9X-RK.h>

// This #include statement was automatically added by the Particle IDE.
#include <RH_RF95.h>
     
#include <SPI.h>
/* 
#define RFM95_RST     1  
#define RFM95_CS      6
#define RFM95_INT     2  
*/
#define RFM95_CS  A2 
#define RFM95_RST 4 
#define RFM95_INT D2 

#define SERIAL_DEBUG

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

#define LED 7
SYSTEM_THREAD(ENABLED);
 
 #define RF95_FREQ 915.0
 
void setup()
{
 //delay(5000);    
    
  pinMode(LED, OUTPUT);
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);
 
  Serial.begin(115200);
  while (!Serial) {
    delay(1);
  }
  delay(100);
 
  Serial.println("Feather LoRa RX Test!");
 
 
  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);
 
  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    Serial.println("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info");
    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);

 
  rf95.setSignalBandwidth(250E3);
 
  rf95.setSpreadingFactor(7);
  rf95.setCodingRate4(8);
  rf95.setPreambleLength(12);
  rf95.setPayloadCRC(1);
  /**/
  // 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(6, false);

}
 
void loop()
{
   
  if (rf95.available())
  {
    // Should be a message for us now
    uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
 
    if (rf95.recv(buf, &len))
    {
      digitalWrite(LED, HIGH);
      RH_RF95::printBuffer("Received: ", buf, len);
      Serial.print("Got: ");
      Serial.println((char*)buf);
       Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);
 
 delay(random(1000, 2000));
 
      // Send a reply
      uint8_t data[] = "And hello back to you";
      rf95.send(data, sizeof(data));
      rf95.waitPacketSent();
      Serial.println("Sent a reply");
      digitalWrite(LED, LOW);
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
}

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