Particle Photon / Electron + RFN95W Long Range Radio

@dalymople That does not surprise me that you got it to compile without all the extra files for the other radios.

Can you provide a screenshot of the file structure for the code your using so we can get an idea of what exactly you did?

I’m only interested in using the RF95 modules so there is no need for all the other files really.

@RWB sure thing. Here is the directory, I am testing the RHReliableDatagram and the RHMesh managers so I have both of them included here.

The includes in the .ino are;

and initializing the driver and manager (this is just the reliable data-gram manager);

@dalymople Thanks for posting that!

So the only thing left is to replace SPI with SPI1 in the RHHardwareSPI.cpp file based on your first post.

Are you going to or have you already tested this with RF95 modules yet?

@RWB I am in the process of physically testing a few modules. I’ll reply when I have finished testing them…

1 Like

I had a terrible range with 2 RF95 modules using the reliable datagram sample code. Not sure why but I couldn’t get two units to communicate more than a few meters apart successfully.

The standard client / Server library code worked great at up to 1 mile away in the suburbs.

@RWB are you sure to set the correct frequency for the RFM95?/ by default the library set the frequency at 433MHZ, you should have to change that to 915.
if (!manager.init())
Serial.println(“init failed”);
// Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
driver.setFrequency(915.0); //
// you can set transmitter powers from 5 to 23 dBm:
driver.setTxPower(5, false);
with 5dbm you can get hundreds meters of range

Yes I had all those settings correct. I tested on the Arduino platform.

Have not had the free time or need to test this on the Particle devices but it does look like the Radio Head library works now on Particle?

Have you tested the radio head library with the Photon yet?

@RWB yes i did a test a moth ago and it work perfect… I will try later to share you one entire project folder

2 Likes

Sweet.

I would like to see your code and pin to pin hookup diagram.

Hello @RWB sorry the delay in sharing the radiohead files that Iam using with photon.
here is the link with the files https://www.4shared.com/zip/uF6KmdiUei/RadioHead_Photon_tested_-.html
Connections:
Photon RFM96
D2----------->DIO0
A2----------->NSS
A3----------->SCK
A4----------->MISO
A5----------->MOSI
GND--------->GND
3V3---------->3.3V IN

I have report from a friend that tested the RFM96 (433MHZ) and get the incredible range of 60km, he learned about the Hope-RF transceiver because of me… now he is in love with LORA, he is been doing very cool stuff…he was able to send data and encoded audio(voice) using LORA… he is not using the radio-head library… he created his own configuration for the RFM95, 96.

1 Like

Sending audio over Lora sounds interesting. Provide a link to that if you can.

Thank you very much for providing your working library and wiring guide for the RFM96 modules!

It’s nice to confirm the RFM95/96 LORA modules work directly with the Particle Devices now!

In your code did you tweak any of the RFM95 settings to get better performance at longer distances? Or did you leave it at the default settings?

@RWB
basically what I did is add several combination of spreading factors vs bandwidth . have a look at RH_RF95.cpp line 120-136 and RH_RF95.h line 579-597. what called my attention if that you mention that you barely get a few meter distance range… and the library without any modification allow you to communicate with devices several hundred meters apart each other.

Good to know. I never came across any info online that gave any idea on how to change these settings or which ones to pick.

So which one do you recommend based on your testing for the following two scenarios?

1 - Longest Range + Short Sensor Data Burst?

2 - Shorter Ranges + Higher Data Rates?

I do see the 2 default settings in the original library now. I never tried the 2nd longer range option because I didn’t know it was an option.

Do you normally set the TX power to 23 for the RFM95 modules running 915mhz?

And have you tested this function any?

I figured it would be useful if you had multiple radios transmitting on the same channel if it actually worked.

this is for very long range but it take 1.5 seconds to send just two double ( Latitude + longitude)

setModemConfig(Bw125Cr48Sf4096); // Bw = 125kHz, Cr = 4/8, Sf12 = 4096 chips/symbol,CRC on Slow+long range

setModemConfig(BW125CR46SF9); // BW = 125 Khz, Cr = 4/6, SF9 = 512 chips/symbol this faster that the previous.

setModemConfig(Bw125Cr45Sf128); // 2: Bw = 125kHz, Cr = 4/5, Sf7 = 128 chips/symbo and this one even faster: ( short data burst)

when testing at home I set power at 5dbm is ok … with 5 dbm and good line of sight one easy get a mile range… I used 23 dbm a few times to test the range … believe or not i do all this just to have fun and learn… I don’t have any of those test currently working in something usefully.
You can use one SDR radio to actually graph the radio signals LINK

i was able to use radio head library (inlcude RHMesh) having 2 moteinos with RFM96 sending data to photon.

#include <RHMesh.h>
#include <RH_RF95.h>

#define CLIENT_ADDRESS 1
#define SERVER1_ADDRESS 2
#define SERVER2_ADDRESS 3
#define SERVER3_ADDRESS 4
char publishString[100];

RH_RF95 driver;//(10,2);  //moteino mega

RHMesh manager(driver, CLIENT_ADDRESS);

2 Likes

@RWB here is the link with the example to create a mesh of RFM96/95
https://www.4shared.com/zip/sN43p16oca/RF95_MESH_TEST.html

Thanks for the recommended settings

I’m going to see if I can get the Reliable Datagram to work now at longer distances without issues.


I downloaded the Mesh code you posted so I can try that also.

For the Mesh code would the Client be the Web Connected Photon who is the end receiver of all the messages coming in from the Server’s 1,2,3 that are Meshed together to get the message back to the main Client radio?

Is that how it works?

Probably one of the best videos I have seen explaining LoRa and its advantages and disadvantages.

I think it’s a great add-on for the Photon & Electron since it allows you push collected data to the internet.

1 Like

Did you hook up the RFM96 exactly like you have mentioned above and get it working with the code you posted?

I’m asking because I tried this last night but the code is not working completely and I think it may be because the DIO1 should be DIO0 because that is the interrupt pin that the Rocket Scream Pro & Adafruit 32u4 + RFM95/96 modules work off of to notify the uC when a new message arrives.

Also in the code you added nothing to tell the Photon what pin you are using for the SPI Chip Select or the interrupt pin as shown in the screen shot below:

I figured if we do this like Adarfruit & Rocket Scream Pro then we also need to tell it what the CS & Interrupt pin were using on the Photon. I figured that would be these settings.

Just wante to check and see what you think before I waste to much more time on getting this to work since it sounds like you have it working already.

I’m guessing the D2----------->DIO1

Should be D2----------->DIO0

@RWB I will double check that when i get back to home… and let you know.

1 Like

I just did a test using the example rf95_reliable_datagram, just to make sure what it work.
on photon put the client… and on arduino or moteino the server… it work perfect…

//PHOTON
/ this the client running on photon
#include <RHReliableDatagram.h>
#include <RH_RF95.h>
//#include <SPI.h>

#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

// Singleton instance of the radio driver
RH_RF95 driver;  //(A2,D2)-->you don't nee set this 
//RH_RF95 rf95(5, 2); // Rocket Scream Mini Ultra Pro with the RFM95W

// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram manager(driver, CLIENT_ADDRESS);

// Need this on Arduino Zero with SerialUSB port (eg RocketScream Mini Ultra Pro)
//#define Serial SerialUSB

void setup()
{
  
  delay(4000);
  Serial.begin(9600);
  while (!Serial) ; // Wait for serial port to be available
  if (!manager.init())
  Serial.println("init failed");  
  driver.setTxPower(10, false);
  driver.setFrequency(915.0);  // hay que setear frecuencia para los rfm96 915
  Serial.println("..this is the Photon as CLient");
}

uint8_t data[] = "Hello World!";
// Dont put this on the stack:
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];

void loop()
{
  Serial.println("Sending to rf95_reliable_datagram_server");

  // Send a message to manager_server
  if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
  {
    // Now wait for a reply from the server
    uint8_t len = sizeof(buf);
    uint8_t from;
    if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
    {
      Serial.print("got reply from : 0x");
      Serial.print(from, HEX);
      Serial.print(": ");
      Serial.println((char*)buf);
    }
    else
    {
      Serial.println("No reply, is rf95_reliable_datagram_server running?");
    }
  }
  else
    Serial.println("sendtoWait failed");
  delay(500);
}


Arduino or moteino +RFM96


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

#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

// Singleton instance of the radio driver
RH_RF95 driver;
//RH_RF95 driver(5, 2); // Rocket Scream Mini Ultra Pro with the RFM95W

// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram manager(driver, SERVER_ADDRESS);

void setup() 
{
 
  Serial.begin(9600);
  while (!Serial) ; // Wait for serial port to be available
  if (!manager.init())
    Serial.println("init failed"); 
   driver.setTxPower(10, false);
  driver.setFrequency(915.0);
  Serial.println("..this is the Moteino or arduino as server +RFM96 @915mhz");

}

uint8_t data[] = "And hello back to you";
// Dont put this on the stack:
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];

void loop()
{
  if (manager.available())
  {
    // Wait for a message addressed to us from the client
    uint8_t len = sizeof(buf);
    uint8_t from;
    if (manager.recvfromAck(buf, &len, &from))
    {
      Serial.print("got request from : 0x");
      Serial.print(from, HEX);
      Serial.print(": ");
      Serial.println((char*)buf);

      // Send a reply back to the originator client
      if (!manager.sendtoWait(data, sizeof(data), from))
        Serial.println("sendtoWait failed");
    }
  }
}