← index #770Issue #999
Related · high · value 2.689
QUERY · ISSUE

lora driver: SX1276 reports incorrect RSSI

openby davefesopened 2023-11-20updated 2023-11-30
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.

6 comments
projectgus · 2023-11-21

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.

davefes · 2023-11-21

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 · 2023-11-21

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.

projectgus · 2023-11-21

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.

davefes · 2023-11-23

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 · 2023-11-30

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.

CANDIDATE · ISSUE

Incorrect SNR parsing in _read_packet of LoRa SX1262 driver

closedby hlym123opened 2025-04-15updated 2025-04-24

🐛 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
dpgeorge · 2025-04-15

@projectgus FYI

projectgus · 2025-04-16

Thanks @hlym123, will fix.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied