Search code examples
loraraspberry-pi-pico

Raspberry Pi Pico sending LoRa messages


I'm using two functions from this pico tracker code:

setup_lora(433.0, 1, "CODEBRANE");
...
SendLoRaPacket(loraBuffer, 16, 0);

and I'm not sure whether it's sending anything. I have an ESP32 receiving on another SX1278 board and I've tested both sender and receiver boards on ESP32 receiving from an ESP8266 which is sending and the boards are fine.

The ESP32/ESP8266 use the LoRa library in the Arduino IDE, but the Raspberry Pi Pico is using the Lora.cpp functions above and that code sets the bandwidth, spreading factor, etc., which the LoRa library doesn't. I'm assuming the Raspberry Pi Pico is sending OK, but the ESP32 isn't receiving anything.

Do the sender and receiver have to be using the exact same settings, mode, bandwidth, spreading factor, implicit/explicit header, etc.?

The Raspberry Pi Pico uses mode 1:

ImplicitOrExplicit = IMPLICIT_MODE;
ErrorCoding = ERROR_CODING_4_5;
Bandwidth = BANDWIDTH_20K8;
SpreadingFactor = SPREADING_6;
LowDataRateOptimize = 0;

would I need to translate these into LoRa library equivalents to get the ESP32 to pick up the Raspberry Pi Pico messages?

E.g.,

LoRa.setSignalBandwidth(20.8E3);
LoRa.setSpreadingFactor(6);
LoRa.implicitHeaderMode();

but there doesn't appear to be an equivalent for ErrorCoding or LowDataRateOptimize.


Solution

  • Communication does depend on matching the various parameters. With help from the developer of the pico-tracker code I got a Raspberry Pi Pico sending messages to an ESP32 Lolin32 Lite which is using the Arduino LoRa library.

    On the Raspberry Pi Pico:

    int main() {
      setup_lora(433, 6, "CODEBRANE");
      unsigned char loraBuffer[20] = "Hello From Pico!";
      while (1) {
        SendLoRaPacket(loraBuffer, 16, 0);
        sleep_ms(5000);
      }
    }
    
    void SetupRFM98(float Frequency, int Mode) {
      ...
      else if (Mode == 6)
      {
        ImplicitOrExplicit = EXPLICIT_MODE;
        ErrorCoding = ERROR_CODING_4_8;
        Bandwidth = BANDWIDTH_62K5;
        SpreadingFactor = SPREADING_8;
        LowDataRateOptimize = 0;
      }
      ...
    }
    

    And on the ESP32 Lolin32 Lite:

    void setup() {
      LoRa.setPins(LORA_SS, LORA_RST, LORA_DIO0);
      if (!LoRa.begin(433E6)) {
        Serial.println("Starting LoRa failed!");
        while (1);
      }
    
      LoRa.setTxPower(17);
      LoRa.setSpreadingFactor(8);
      LoRa.setCodingRate4(8);
      LoRa.setSignalBandwidth(62.5E3);
    }