Non-default Spreading Factor and/or Bandwidth setting not working LoRa

Hi! I have 2 LoRa Sx1278 Ra-02 modules, alongside with 2 Arduino Pro Mini boards, one is working as a Receiver and one as a Transmitter. The problem is that if I try to change the default Spreading Factor and/or Signal Bandwidth settings, the Receiver doesn't receive anything, or maybe the transmitter is not sending anything...

TX code:

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

EasyButton Button(3);

long code = 1469543;

void setup() {
  
  pinMode(13, OUTPUT);
  pinMode(3, INPUT_PULLUP);

  Button.begin();

  Button.onPressed(Radio);

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

  Serial.println("LoRa Sender");

  if (!LoRa.begin(433E6)) {
    
    Serial.println("Starting LoRa failed!");
    digitalWrite(13, HIGH);
    while (1);}
  
  LoRa.setTxPower(10);
  LoRa.setSpreadingFactor(12);
  LoRa.setSignalBandwidth(31.25E3);

}

void Radio() {

    LoRa.beginPacket();
    LoRa.print(code);
    LoRa.endPacket();
    delay(1000);

}

void loop() {

  Button.read();

}

RX code:

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

long code = 1469543;

void setup() {
  
  pinMode(9, OUTPUT);
  
  Serial.begin(9600);
  while (!Serial);

  Serial.println("LoRa Receiver");

  if (!LoRa.begin(433E6)) {
    Serial.println("Starting LoRa failed!");
    digitalWrite(9, HIGH);
    while (1);}
  
  digitalWrite(9, LOW);

}

void loop() {
  
  digitalWrite(9, LOW);

  int packetSize = LoRa.parsePacket();
  
  if (packetSize) {
   
    char buffer[packetSize + 1]; // +1 for the trailing null char
    
    for (int i = 0; i < packetSize; i++) buffer[i] = (char)LoRa.read();
    
    buffer[packetSize] = '\0';
    
    long value = strtol(buffer, nullptr, 10);
    
    if(code == value) {
      
      digitalWrite(9, HIGH);
      delay(1000);}
 
  }
}

You did make the same change in the transmitter and receiver ?

Just spotted that.

Dont use such a low bandwidth, to use a bandwidth below 62.5khz at 434Mhz or below 125khz at 868Mhz, you really need modules with TCXOs fitted, which most all SX1278 modules do not have.

Receiver? Do I have to change something there?

Ok, I'll try with the 62.5khz one...

Of course.

Transmitter and receiver need to use the same LoRa settings.

1 Like

and how would I change that for the receiver? "LoRa.setRxSpreadingFactor(12)"?
Or like for the TX?

Use the same code as you would when changing the defaults in the transmitter.

I changed that, now it's working, but there is a longer delay receiving the message, this should be normal right?

The higher the spreading factor and the lower the bandwidth the longer the packet takes to transmit.

Semtech do an airtime calculator that will tell you the airtime for a packet.

So, now I have achieved the best LEGAL settings for range?

  LoRa.setTxPower(10);
  LoRa.setSpreadingFactor(12);
  LoRa.setSignalBandwidth(62.5E3);

To work out if its 'Legal' you would need to know the duty cycle limits for your part of the world, the air time of the packet and how often the packet it sent.

Ok, thank you for your help!

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