Hi challard, thanks for the link!
Strictly speaking, this is not a bug, but a feature since it requires both:
- software changes to apply optimized PA settings
- hardware changes because output impedance will change
Software changes alone will reduce output power, which is not what we want, right? But if one has to make changes to hardware for optimal 14dBm output from HP path, then why not use LP path altogether? Maybe that’s the reason why both HP and LP exist? Because their chosen PA requires different matching network for lower power?
Anyway, what I decided to do is to compensate for power loss in the software, so that observed transmission power does not change. I’ve got less current than in stock firmware, but still more than one would expect from optimized hardware.
Here is what I’ve measured before and after the patch:
| LoRaWAN power | PHY tx power, dBm | ST firmware, mA | Patched, mA |
| ------------: | ----------------: | --------------: | ----------: |
| 0 | 14 | 86 | 60 |
| 1 | 12 | 77 | 59 |
| 2 | 10 | 70 | 46 |
| 3 | 8 | 63 | 44 |
| 4 | 6 | 59 | 42 |
| 5 | 4 | 52 | 39 |
| 6 | 2 | 46 | 36 |
| 7 | 0 | 41 | 32 |
One caveat: LoRaWAN middleware defines Max EIRP as 16dBm for EU868 region and antenna gain as 2.15dBi and asks SUBGPHY to transmit
floor(16 - 2.15) = 13dBm at TX_POWER_0 (default). This is not correct IMHO, since it is allowed to transmit 14dBm(25mW) via dipole antenna in Europe. So, I corrected Max EIRP to 16.2, it is included in the patch.
Patch is made for
STM32CubeWL Firmware Package V1.1.0 / 16-June-2021, but should also work for 1.0.0. Just look inside, there are couple of small changes. It will be overwritten by code generation from CubeMX, so be aware.
All that is relevant for slower bitrates, since in DR5 it is already possible to build a sensor device which would run for 10 years on 2 AAA batteries. This is with the default settings for EU868 and ST firmware. Effect for DR5 from this optimization will be marginal because TX uses just a part of the total power budget. Current consumption for RX, sensor and idling will be the same.
A word about measuring transmitted power. I used RSSI on my own gateway and HackRF One. This is by no means precise measurement, I just compared signal strength before and after the patch. Would be nice if somebody with proper equipment could confirm that max transmitted power is within the legal EU boundaries.
Thick disclaimer: I provide this patch for educational purposes only as part of my own R&D activities, do whatever you want with it, I am not responsible for anything.