micropython-lib icon indicating copy to clipboard operation
micropython-lib copied to clipboard

lora driver: SX1276 reports incorrect RSSI

Open davefes opened this issue 1 year ago • 6 comments

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.

davefes avatar Nov 20 '23 19:11 davefes

Hi @davefes,

Thanks for noticing this, it's a bug. It should be based on this section of the SX1276 datasheet:

Section 3.5.5 of the datasheet

Meaning the implementation should be something like:

# units: dBm
rx_packet.rssi = self._reg_read(_REG_PKT_RSSI_VALUE) - (157 if self._rf_freq_hz > 525_000_000 else 164)

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.

projectgus avatar Nov 21 '23 06:11 projectgus

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".

davefes avatar Nov 21 '23 07:11 davefes

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.

davefes avatar Nov 21 '23 19:11 davefes

Thanks @davefes! Will leave this issue open until there's a fix.

Another odd behaviour noted: the first RSSI after a re-boot is 5dB better then subsequent RSSI readings.

Interesting. I assume that's probably an artifact of the module, although I don't know what it would be down to.

projectgus avatar Nov 21 '23 22:11 projectgus

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:

  1. As signal strength increases (RSSI>-100dBm), the linearity of PacketRssi is not guaranteed and results will diverge from the ideal 1dB/dB ideal curve. When very good RSSI precision is required over the whole dynamic range of the receiver, two options are proposed:

Rssi in RegRssiValue offers better linearity. Rssi can be sampled during the reception of the payload (between ValidHeader and RxDone IRQ), and used to extract a more high-signal RSSI measurement When SNR>=0, the standard formula can be adjusted to correct the slope: RSSI = -157+16/15 * PacketRssi (or RSSI = - 164+16/15 * PacketRssi)

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.

davefes avatar Nov 23 '23 05:11 davefes

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.

davefes avatar Nov 30 '23 05:11 davefes