B4R Question ESP8266 RSSI for particular AP

BertI

Member
Licensed User
Longtime User
Anyone know if there is a way to get the RSSI value for a given link between the ESP8266 and some access point to which it is connected without having to do a whole network scan process? For example to be able to regularly check the connection strength to the router in a non onerous way
 

BertI

Member
Licensed User
Longtime User
Indeed, but this just mentions using full network scan (as I understand it) which takes quite a bit of time. Just wondered if there was some way to get the RSSI level only of the network currently connected to a bit more neatly and less power consuming
 
Upvote 0

thetahsk

Active Member
Licensed User
Longtime User
Upvote 0

BertI

Member
Licensed User
Longtime User
Thank you for that pointer.

So for anyone else who bumbles through these things like myself, the following looks to do the job:

B4X:
#if C
void GetRSSI (B4R::Object* o) {
b4r_main::_rssi = WiFi.RSSI();
}
#End if


Where you first declare a variable to collect the RSSI value:

B4X:
Private RSSI as Int

and then

B4X:
RunNative("GetRSSI", Null)

will get the RSSI value as a -dB value into the variable RSSI
 
Upvote 0

BertI

Member
Licensed User
Longtime User
Yes that's a good point. I tried it without being connected and got a value back of 31 (that's plus 31) so I guess also an indicator in itself that you are not connected - though it was just one test so can't assume, without knowing the underlying detail, that this is a reliable alternative to checking if connected first.
 
Upvote 0

thetahsk

Active Member
Licensed User
Longtime User
Yes that's a good point.....

Convert this code snippet from above to B4R and check the return value against -1

B4X:
/*
   Return the quality (Received Signal Strength Indicator)
   of the WiFi network.
   Returns a number between 0 and 100 if WiFi is connected.
   Returns -1 if WiFi is disconnected.
*/
int getQuality() {
  if (WiFi.status() != WL_CONNECTED)
    return -1;
  int dBm = WiFi.RSSI();
  if (dBm <= -100)
    return 0;
  if (dBm >= -50)
    return 100;
  return 2 * (dBm + 100);
}
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…