Skip to content

I believe the RSSI function is returning the wrong number. #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nlbutts opened this issue Nov 26, 2019 · 15 comments
Closed

I believe the RSSI function is returning the wrong number. #31

nlbutts opened this issue Nov 26, 2019 · 15 comments
Assignees
Labels
bug Something isn't working

Comments

@nlbutts
Copy link

nlbutts commented Nov 26, 2019

On line 553 the RSSI register (for Lora) is read and 137 is subtracted from the value. During testing I seem to lose the LORA signal at -101 dBm. Looking at the Semtech data sheet (section 5.5.5) the formula for RSSI is:
RSSI (dBm) = -157 + Rssi, (when using the High Frequency (HF) port) or RSSI (dBm) = -164 + Rssi, (when using the Low Frequency (LF) port)

Working the numbers back when this library reads -101, the register would have contained 36, running the correct formula gives me an RSSI of -121 dBm. I'm running the Lora radio at 125 KHz bandwidth and a SF of 7, which should give me a theoretical -125 dBm receive sensitivity. This seems in the realm of possibility.

Am I missing something or is the number incorrect in the code?

@brentru
Copy link
Member

brentru commented Nov 26, 2019

@nlbutts
The library code uses RFM9x Datasheet, which seems like it doesn't take HF/LF into account like the SX1276 formula (https://www.digikey.com/en/datasheets/rf-solutions/rf-solutions-rfm95_96_97_98w):

Microsoft_Word_-_RFM95_96_97_98W_doc

return self._read_u8(_RH_RF95_REG_1A_PKT_RSSI_VALUE) - 137

I'd be open to implementing the RSSI formulas from the SX datasheet in this library, unless you'd want to take this on and open a PR?

@nlbutts
Copy link
Author

nlbutts commented Nov 27, 2019

It appears Hoperf fixed the datasheet. I just downloaded Version 2.0 of the datasheet from their web-site and it shows the same formula as Semtech's datasheet.

Excuse my ignorance, but what is a PR?

@brentru
Copy link
Member

brentru commented Nov 27, 2019

@nlbutts Cool - confirmed the latest hoperf DS reflects the semtech formulas. (https://www.hoperf.com/data/upload/portal/20190801/RFM95W-V2.0.pdf).

PR as in a pull request to this repository. Alternatively I can update the code and library to reflect the issue

@kattni kattni added the bug Something isn't working label May 4, 2020
@kattni
Copy link
Contributor

kattni commented May 4, 2020

@brentru Is this something you're still working on?

@nlbutts
Copy link
Author

nlbutts commented May 8, 2020

I wanted to use the SX127x parts in both LoRa and FSK mode, so I switched to the UPM code base.

@brentru
Copy link
Member

brentru commented Dec 21, 2020

@jerryneedell Was this ever implemented in any of the work you've done for RFM9x?

@jerryneedell
Copy link
Contributor

@brentru I have not but it look like a good thing to do -- there are also some proposed changes in #51 that I have been meaning to test and implement. Unfortunately, I have not had much time available recently. That should be improving this week.
If you want this done immediately, then you are probably better off doing it yourself. I hope to be able to get to this later this week or next week.

@jerryneedell
Copy link
Contributor

jerryneedell commented Dec 22, 2020

looks like this will work...unless I am missing somethng.

    @property
    def rssi(self):
        """The received strength indicator (in dBm) of the last received message."""
        # Read RSSI register and convert to value using formula in datasheet.
        # Remember in LoRa mode the payload register changes function to RSSI!
        raw_rssi = self._read_u8(_RH_RF95_REG_1A_PKT_RSSI_VALUE)
        if self.low_frequency_mode:
            raw_rssi -= 157
        else:
            raw_rssi -= 164
        return raw_rssi

@brentru
Copy link
Member

brentru commented Dec 22, 2020

@jerryneedell Yeah, checked the v2 of the hoperf datasheet and the code in this library looks correct to me.

@brentru brentru closed this as completed Dec 22, 2020
@jerryneedell
Copy link
Contributor

It has not been updated yet

@jerryneedell
Copy link
Contributor

@brentru I'm confused. Are you saying it does not need to be changed?

@brentru brentru reopened this Dec 22, 2020
@brentru
Copy link
Member

brentru commented Dec 22, 2020

@jerryneedell Sorry - I misread your post as a code snippet from master! The code you posted looks good & matches the Semtech and hoperf datasheets.

@jerryneedell
Copy link
Contributor

@brentru I was planning to combine this with #51. Is that OK or would you prefer separate PR's?

@brentru
Copy link
Member

brentru commented Dec 22, 2020

@jerryneedell That's OK - fold it in!

@jerryneedell
Copy link
Contributor

fixed by #57

@brentru brentru closed this as completed Dec 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants