I am trying to get RSSI of a network without connecting to it directly but I get an error " error: cast from 'const char*' to 'uint8_t {aka unsigned char}' loses precision [-fpermissive]"
char ssid[]="GreenNET";
long rssi = 0;
void updateRSSI(){
rssi = WiFi.RSSI(ssid);
}
I am following this: https://www.arduino.cc/en/Reference/WiFiRSSI except I am not passing password since it is not required WiFi.RSSI(wifiAccessPoint);
1 Answer 1
The argument passed to RSSI()
must be an integer indicating the array index of the SSID of the WiFi network whose RSSI you want to get. To get that integer, you must first scan for networks.
char ssid[] = "greenNet";
byte num_ssids = 0;
long rssi = 0;
num_ssids = WiFi.scanNetworks();
for (byte net = 0; net < num_ssids; net++){
rssi = WiFi.RSSI(net);
Serial.print(WiFi.SSID(net)); Serial.print(": ");
Serial.println(rssi);
}