How to set SF and BW in CUBE-LRWAN?


I am trying to find where in the mentioned code I can set spreading factor, bandwidth and maybe even specify the exact frequency I want the node to transmit at. I know I am not supposed to do that but it is for testing purposes where I need to control these parameters.

I thought I could do it in RegionEU868.h with setting DR but it doesn’t seem to really do the trick.


BW and SF are determined by datarate (DR). Go to RegionEU868.h file and search for:


and set it to your desired value. You can find what each DR value means in Region.h file.

You can also set the node to send data at the exact same frequency each time. Go to RegionEU868.h again and search for:

#define EU868_LC1

now change the frequency value in EU868_LC1, LC2, LC3 to the desired value and you are set. Be careful to set frequency to one of the three frequencies already specified in the defines as these are also channel frequencies gateway is listening at. In case you defined more channel frequencies for your gateway you can probably use those too.

If you are not in EU I would assume everything is the same except for the file name you are editing your values in e.g. for US go to RegionUSXXX etc.

Note: I noticed ADR has to be turned on (1) in main.c file in order for custom datarate to work?!

Hope this was/will be of some help to someone! :slightly_smiling_face:

In main.c you will find a define which deals with spreading factor and bandwith:

* LoRaWAN Default data Rate Data Rate
 * @note Please note that LORAWAN_DEFAULT_DATA_RATE is used only when ADR is disabled 

DR_0 to DR_15 is present in region.h and define all configuration covered by i-cube-lrwan.

I think we have different I-LRWAN-CUBE versions. I have


in RegionEU868.h file and


  • LoRaWAN Adaptive Data Rate
  • @note Please note that when ADR is enabled the end-device should be static
    #define LORAWAN_ADR_ON 0//1

in main.c

If i turn LoraWAN ADR OFF like in the text above, the node starts sending all messages with SF 12 and BW 125Khz every 2 mins and 13 seconds even though my default datarate is defined as DR_5 which should give spreading factor 7.

I noticed i can actually set SF with setting default DR but only if ADR is ON.

Have you ever tried specifying the exact frequency the node is sending at?

in the example end node sends the message in 8 different channels what I did was to configure all channels to a single frequency. in my case I configured it in the file RegionUS915.c line 509 the comment and I put NvmCtx.Channels [i] .Frequency = 903900000;