nRF24 / RF24

OSI Layer 2 driver for nRF24L01 on Arduino & Raspberry Pi/Linux Devices
https://nrf24.github.io/RF24
GNU General Public License v2.0
2.23k stars 1.02k forks source link

[Question] R24.h, testRPD(void) "Strong signal > 64dBm" : "Weak signal < 64dBm" #946

Closed hrolofs closed 8 months ago

hrolofs commented 8 months ago

Hi,

Just a question about the testRPD function. I am a little confused about the description of testRDP() in RF24.h

    /**
     * Test whether a signal (carrier or otherwise) greater than
     * or equal to -64dBm is present on the channel. Valid only
     * on nRF24L01P (+) hardware. On nRF24L01, use testCarrier().
     *
     * Useful to check for interference on the current channel and
     * channel hopping strategies.
     *
     * @code
     * bool goodSignal = radio.testRPD();
     * if(radio.available()){
     *    Serial.println(goodSignal ? "Strong signal > 64dBm" : "Weak signal < 64dBm" );
     *    radio.read(0,0);
     * }
     * @endcode
     * @return true if a signal less than or equal to -64dBm was detected,
     * false if not.
     */
    bool testRPD(void);

The mixing of positive and negative values confuses me. It would be easier if all values in this description were negative.

Please correct me if I am wrong.

-50dBm is better than -64dbm (-50 > -64) -70dBm is worse than -64dBm (-70 < -64) (all values are negative)

Shouldn't it then read: Strong signal > -64dBm, Weak signal < -64dBm

This is also misleading for me.

     * Test whether a signal (carrier or otherwise) greater than
     * or equal to -64dBm is present on the channel.

     * @return true if a signal less than or equal to -64dBm was detected,

mixing "greater than or equal" and "less than or equal"

2bndy5 commented 8 months ago

Shouldn't it then read: Strong signal > -64dBm, Weak signal < -64dBm

Yes, the example code should be updated. Although a "Weak signal" could also mean "no signal". We have no way of knowing given the nRF24L01's SPI intrerface.

     * @return true if a signal less than or equal to -64dBm was detected,
     * false if not.

This should read "greater than or equal" not "less than or equal".

(all values are negative)

This is not true for all radios that use the nRF24L01 chip. Certain manufacturers tweak the PA/LNA processing to achieve > 0 dBm (ebyte modules can get as high as +20dBm).

2bndy5 commented 8 months ago

We have also found from using reverse engineering tactics (for sniffing packets from a non-nRF24L01 radios) that general listening can be more sensitive (> -80 dBm IIRC) than testRPD() reports.

The main discrepancy is that the RPD flag in the radio's registers was added for compliance testing mandated by government regulations. Meaning testRPD() satisfies the required carrier wave [hardware] tests, but it does not fully describe the actual performance during RX operation. We have a promiscuous-scanner branch to experiment with this (and improve the scanner examples).

TMRh20 commented 8 months ago

...a "Weak signal" could also mean "no signal". We have no way of knowing given the nRF24L01's SPI intrerface.

Hmm, I think one could call the available(); function immediately after calling testRPD(); or testCarrier();

        radio.startListening();
        delayMicroseconds(128);
        radio.stopListening();

        // Did we get a carrier?
        if (radio.testCarrier()) {
          ++values[i];
        }else
        if(radio.available()){
          ++weakValues[i];
        }

Not tested, but maybe it could work?

Incoming commit and PR, please verify I got it right this time lol. @2bndy5 @hrolofs

2bndy5 commented 8 months ago

I think it would work with a non-plus variant. The carrier wave test setup on non-plus variants was very much like sending a payload full of 0xFF with no ACKs.

hrolofs commented 8 months ago

Many thanks to everyone for the quick response to my questions and the fix in the documentation. :-)