@projectgus FYI
QUERY · ISSUE
lora driver: SX1276 reports incorrect RSSI
bug
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.
CANDIDATE · ISSUE
Incorrect SNR parsing in _read_packet of LoRa SX1262 driver
🐛 Bug Description
micropython/lora/lora-sx126x/lora/sx126x.py, line: 599
In sx1262.py, the SNR value is parsed incorrectly in _read_packet. The driver currently does:
rx_packet.snr = pkt_status[2] # Incorrect
pkt_status[2] is a signed 8-bit integer in two’s complement format (unit: dB × 4), and should be converted before use.
raw_snr = pkt_status[2]
if raw_snr >= 128:
raw_snr -= 256 # convert to int8
2 comments
Thanks @hlym123, will fix.
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.