Change Lora Parameters Radiohead library

Hello, I recently made a post about setting Lora parameters with the Lora.h library but was unsuccessfull so I am trying the Radiohead library. As was the case for Lora.h my radios worked well with the example code rf95_server and rf95_client.
I now wish to change parameters so I tried the example from comments in the sketch.

// Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
// You can change the modulation parameters with eg
// rf95.setModemConfig(RH_RF95::Bw500Cr45Sf128);

From the RH_RF95.h I found available "canned" configurations.
Bw125Cr45Sf128 = 0, ///< Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Default medium range
Bw500Cr45Sf128, ///< Bw = 500 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Fast+short range
Bw31_25Cr48Sf512, ///< Bw = 31.25 kHz, Cr = 4/8, Sf = 512chips/symbol, CRC on. Slow+long range
Bw125Cr48Sf4096, ///< Bw = 125 kHz, Cr = 4/8, Sf = 4096chips/symbol, low data rate, CRC on. Slow+long range
Bw125Cr45Sf2048, ///< Bw = 125 kHz, Cr = 4/5, Sf = 2048chips/symbol, CRC on. Slow+long range
} ModemConfigChoice;

I chose this one Bw125Cr45Sf2048 and set tx and rx radios then compared the rssi to the rssi using the default parameters set in the example code. (tx power=2 with rx in the opposite end of the building) I got exactly the same average rssi (-84) .

// rf95_client.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client
// 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 rf95_server
// Tested with Anarduino MiniWirelessLoRa, Rocket Scream Mini Ultra Pro with
// the RFM95W, Adafruit Feather M0 with RFM95
 
#include <SPI.h>
#include <RH_RF95.h>

// lilygo T3 v2.1.6
// lora SX1276/8
#define LLG_SCK 5
#define LLG_MISO 19
#define LLG_MOSI 27
#define LLG_CS  18
#define LLG_RST 23
#define LLG_DI0 26
#define LLG_DI1 33
#define LLG_DI2 32

#define LED 25

// oled
#define LLG_OLED_SDA 21
#define LLG_OLED_SCL 22


 
// Singleton instance of the radio driver
RH_RF95 rf95(LLG_CS, LLG_DI0); // slave select pin and interrupt pin, [heltec|ttgo] ESP32 Lora OLED with sx1276/8
 
void setup() 
{
  pinMode(LED, OUTPUT);  
  
  // Ensure serial flash is not interfering with radio communication on SPI bus
//  pinMode(4, OUTPUT);
 
  Serial.begin(9600);
  
  rf95.init();
    //Serial.println("init failed");
    // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
    // You can change the modulation parameters with egPredefined configurations( bandwidth, coding rate, spread factor ):sf7=  sf10=1024  sf11=2048  sf12=4096
    // Bw125Cr45Sf128     Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Default medium range
    // Bw500Cr45Sf128     Bw = 500 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Fast+short range
    // Bw31_25Cr48Sf512   Bw = 31.25 kHz, Cr = 4/8, Sf = 512chips/symbol, CRC on. Slow+long range
    // Bw125Cr48Sf4096    Bw = 125 kHz, Cr = 4/8, Sf = 4096chips/symbol, low data rate, CRC on. Slow+long range
    // Bw125Cr45Sf2048    Bw = 125 kHz, Cr = 4/5, Sf = 2048chips/symbol, CRC on. Slow+long range **********************  SF11
  rf95.setModemConfig(RH_RF95::Bw125Cr45Sf2048);
  rf95.setTxPower(2, false); // with false output is on PA_BOOST, power from 2 to 20 dBm, use this 
  setting for high power demos/real usage
  rf95.setFrequency(915.0);
  //rf95.setCADTimeout(500);
  // 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 2 to 20 dBm:
  //  rf95.setTxPower(20, false);

SPI.begin(LLG_SCK,LLG_MISO,LLG_MOSI,LLG_CS);
}
 
void loop()
{
  digitalWrite(LED, HIGH); //turn on LED for tx indicator 
  delay(500); 
  digitalWrite(LED, LOW);   
  Serial.println("Sending to rf95_server");
  // Send a message to rf95_server
  uint8_t data[] = "Hello World!";
  rf95.send(data, sizeof(data));
  
  rf95.waitPacketSent();
  // Now wait for a reply
  uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);
 
  if (rf95.waitAvailableTimeout(3000))
  { 
    // 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("recv failed");
    }
  }
  else
  {
    Serial.println("No reply, is rf95_server running?");
  }

  digitalWrite(LED, LOW);
  delay(6000);
 
Serial.println(RH_RF95_OUTPUT_POWER);
}

The Sandeep LoRa library, when used correctly, does most definetly, absolutly allow the LoRa parameters to be changed.

If they dont change for you, there is something wrong with your code, changeing to another library is not the way forward.

Although having said that, there is a LoRa library that has functions that will print, in plain language, to the serial monitor what the current settings of the LoRa device are.

Blockquote
The Sandeep LoRa library, when used correctly, does most definetly, absolutly allow the LoRa parameters to be changed.
Blockquote
Would love to see example code, I just can't find it.

Blockquote
Although having said that, there is a LoRa library that has functions that will print, in plain language, to the serial monitor what the current settings of the LoRa device are.

Blockquote
That would be very helpfull,I have scoured the net for such.

you make Sandeep Mistry LoRa library radio parameter changes in the API.md file. Starting point: ## Radio parameters, to end of file

Wow, with all the sites and videos I've watched no one has ever mentioned that file.
I opened the file and entered 12 for spreading factor.
LoRa.setSpreadingFactor(12) Saved file and uploaded to 1 radio. Radios still worked so I must be doing this wrong. Never worked with md files before.

Spreading Factor

Change the spreading factor of the radio.

LoRa.setSpreadingFactor(spreadingFactor);
  • spreadingFactor - spreading factor, defaults to 7

Supported values are between 6 and 12. If a spreading factor of 6 is set, implicit header mode must be used to transmit and receive packets.

Watching videos is often a waste of time. The written documentation and source code are better resources.

Did you look at the examples that the library provides ?

There is an example called;

LoRaSetSpread.ino

What do you think that example might do ?

Which parameter did you expect to change the signal strength?

1 Like

I assumed that the higher spreading factor would increase the rssi, but I believe now that this is wrong. Higher receiver sensitivity does not mean higher rssi. So I think my assumptions are wrong and my radios probably are functioning normal. Thanks for the pointed questions.

Hi,
What range are you getting with -84db RSSI?

What frequency and are your Lora units.
What are you using as antennae?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

It is wrong.

The receiver at SF7 operates down to -7.5dB SNR and at SF12 down to -20dB SNR, so at SF12 the receiver can detect signals that are 12.5dB weaker, or about 4 times further away. The down side of the extra distance is that the packets take around 20 times longer to send.

Although having said that, there is a LoRa library that has functions that will print, in plain language, to the serial monitor what the current settings of the LoRa device are.

srnet, I think I have that straight now - thanks
Tom, I'm just testing my 915 mhz modules at opposite ends of a multiroom building, now I need to do outdoor range testing.

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