The NRF24 chips don’t provide a “Received Signal Strength Indicator” (RSSI) like a WiFi link does, but there is a way to get an indicator of link quality which was good enough for my application.
When the NRF24 chip doesn’t receive an acknowledge for a transmitted message, it tries to send it again, up to 15 times. The number of retries needed to get the message to its destination (“automatic re-transmit count”, ARC) is held in a chip register, and that value is exposed by the MySensors library function transportHALGetSendingRSSI()
, in a roundabout way. The function returns a value between -29 (no retries were necessary) and -104 (gave up after 15 retries), by calculating (-29 - (8 * number_of_retries))
… don’t ask me to explain this, please ask the developers of the MySensors library.
I simply undo that math by calculating (-(transportHALGetSendingRSSI()+29))/8
to get the number of retries needed for the most recently sent message, and accumulate that for N messages, to get a total number of retries R. The “success rate” S is then simply S = (N+R)/N
. It can range from 100% (perfect success, no retries needed) to about 6% (bad, 15 or more retries needed per message).
My sensor nodes collect ARC statistics for every message they send, and report the “success rate” once a day or so. My logging app collects these reports and shows me the link quality for all sensor nodes at a glance. My gateway and repeater also keep track of their success rate in sending messages to sensor or actuator nodes, and show those through their web UI. In combination, I get a good overview of the “health” of my MySensors network.