Questions about TX power

Hi,

I’m working on RAK4631 and I got some questions about SX126x based device and I couldn’t found accurate informations.

I met some “strange” issues during joining phase : it seems that when I use a good antenna, things goes as expected (device join_request SF9 => After joining phase it directly use SF9), and when I use less performing antennas, I observe a gap between SF used in Join request and SF used after joining (for example, join request use SF10, messages after use SF7). So I am investigating on TX power used.

In other LoRa libraries it’s common to set up tx powwer in fucntion of your antenna performance.

I found out that it exists a lmh_tx_power_set() function :

  • What arguement should I use ? Is it the same as the array which can be found in this topic ? RAK811 tx power
  • What’s the default configuration ?

Regards !

RAK811 and RAK4631 are using complete different LoRa/LoRaWAN libraries.

On the RAK4631 (Arduino BSP) you set the TX power with the lmh_tx_power_set(uint8_t tx_power); function. The value is from 0 (highest TX power) to 10 (lowest TX power).
The actual dBm value depends on the LoRaWAN region you are using.

Different SF for join and data transmission can happen.
For most LoRaWAN regions, the DR (SF + BW) is fixed for the join process.
After join, the packets are sent with the DR that you set during the LoRaWAN stack initialization


lmh_init(lmh_callback_t *callbacks, lmh_param_t lora_param, bool otaa, eDeviceClass nodeClass = CLASS_A, LoRaMacRegion_t region = LORAMAC_REGION_EU868, bool region_change = false);


with the lmh_param_t lora_param structure, or you can change it with lmh_datarate_set(uint8_t data_rate, bool enable_adr);

If I am not wrong it’s not exactly that : speaking about radio power a device is limited by regulation which depends on your Region (on this point we both agree). But the “final” radio power is based on two main factors : radio IC configuration (tx power here), and “performance” of the radio circuit (where antenna is commonly the most important part). So if I use a +0 dBm antenna, it’s not the same power as if I use a +5 dBm antenna, and I can’t adjust that in firmaware. Before using RAK stuff I used CMWX1ZZABZ based board with this stack : GitHub - GrumpyOldPizza/ArduinoCore-stm32l0: Arduino Core for STM32L0
In this example there is available function LoRaWAN.setAntennaGain(2.0) which allow to adjust power depending on your antenna performance.

And digging a litlle in LoRaWAN lib I found that line

#define EU868_DEFAULT_ANTENNA_GAIN 2.15f

I did not find a function to adjust this, it just take this value durint initialization.

If ADR is on I’m not sure of that : except in my actual case, every time I joined I got the DR set by the gateway, which most of the time was the same as the join request (speaking about SF, SF9 join leads to a SF9 messages after join, which may be adjusted after by ADR process).

Correct, the default antenna gain is a #define, so it is a fixed value and you have to change the .h files to adjust it.
It should be possible to make this as a variable and provide a function to set it.
Needs to be discussed with the owner of the library (which is very busy, I can assure you :wink:)

But he welcomes improvements as pull requests :grin:

If you use ADR, yes, then the LNS takes control over your DR, otherwise it is set with the library calls.

Yeah a real moron :joy: :joy: :rofl:

I already planned a pull request for other features (like getting SF used and the number of join trial) so I will work on it too :wink:

Thanks a lot.
Looking forward to it.