LoRA set up in SF7 Nucleo L432KC

Do you know how to set up the Spreading Factor to 12 in an Mbed-OS LoRaWAN protocol APIs to connect to a LoRaWAN network using OTAA?


I’m trying to make LoRA node to use Spreading Factor SF12, because the default one is SF7. I know that in the PHY layer we can change Radio configurations. There are several examples to change between the different sub-GHz frequency bands, however, I can’t find one on how to change the LoRa modulation SF between 7 and 12 and with a bandwidth of 125 kHz. I’m using an SX1276 radio at EU 868 MHz config.

In the source code you can find the SF7-12 different configurations, but there is not a clear way to set it up. These configs are the (8 #define DR_0, DR_, etc).

In the configuration file in the Phy part you find some example like this:

        "phy": {
        "help": "LoRa PHY region. 0 = EU868 (default), 1 = AS923,
         2 = AU915, 3 = CN470, 4 = CN779, 5 = EU433, 
         6 = IN865, 7 = KR920, 8 = US915, 9 = US915_HYBRID",
        "value": "0"

But there is no examples or description for the Spreading Factor.

I would like to change it via source code, rather than the configuration file.


lorawan.set_datarate(0); // SF12 125 KHz

Make sure to:

  1. Disable ADR.
  2. Either use ABP, or call the function above in the JOIN_SUCCESS event handler. This is because join procedure always starts at SF7, and then keeps the data rate on which the join succeeded.