@hlym123 thanks again for the very clear bug report!
lora driver: SX1276 reports incorrect RSSI
Maintainer edit: Continuation from discussion at https://github.com/orgs/micropython/discussions/12989
For a Hope Radio RF96 (RFM96W) the RSSI readings seem to calculated incorrectly. I generally see about -110dBm where errors start creeping-in. Two other Micropython LoRa implementations report -120 or thereabout dBm for similar "errors*.
Is the formulae:
# units: dBm
rx_packet.rssi = self._reg_read(_REG_PKT_RSSI_VALUE) - (157 if self._pa_boost else 164)
valid for this chip? I do not understand why pa_boost is in this formulae.
lora: Fix SNR value in SX126x received packets.
Wasn't being treated as a signed value. Closes #999 .
Tested on NUCLEO-WL55 (same underlying driver as SX126x), by moving the transmitter far enough away for SNR to be <0dB.
@dpgeorge Oops, thanks for bumping the manifest version!
thanks for bumping the manifest version!
No worries! It's a habit now.
Hi @davefes,
Thanks for noticing this, it's a bug. It should be based on this section of the SX1276 datasheet:
Meaning the implementation should be something like:
Are you in a position to test this version and submit a PR to change it? If not, I'll get to it as soon as I have time.
Not until the weekend. Submit a PR ... it would be a first for me. As long as it works it's way into library I am OK with the "under-reporting".
I did check the RSSI at the receiver increased by turning off PA_BOOST at the receiver. Of course I didn't get an ACK at the sender. Another odd behaviour noted: the first RSSI after a re-boot is 5dB better then subsequent RSSI readings.
Thanks @davefes! Will leave this issue open until there's a fix.
Interesting. I assume that's probably an artifact of the module, although I don't know what it would be down to.
Change VALUE to VAL
rx_packet.rssi = self._reg_read(_REG_PKT_RSSI_VAL) - (157 if self._rf_freq_hz > 525_000_000 else 164)and RSSI values around -117dBm are when errors started appearing. Still see 4 or 5dB higher on the first RSSI reading. I am sure I haven't seen this happen on other implementations, but I will go back and check.
Edit:
just re-checked Wei's implementation and it reads -123 or -124dBm (at onset of errors) after a re-boot and that stays the same after that. The distance between RX and TX remained the same, so TX power and RX sensitivity appear to be identical with both S/Ws.
I believe you are both using the same RSSI register value. I did notice in the datasheet that there is another RSSI register:
Practically-speaking, I think the most useful aspect of RSSI is to give the user some rough idea of the excess link budget one has. If I see errors at -117dBm and my RSSI is -100dBm then I know I have ~17dB of margin.
Confirm that RSSI is the same on the first loop and subsequent loops with your chips ... then I'll just say it is problem with Hope Radio RF96 chips and I will close this issue.