Good morning.
I use several ESP32s and depending on where I work, I use a different network
I have a different network in each of the three locations.
At the end I would like the program to select which one is active.
I found the program to scan the network and I want to select the active one from one of the three
I put the program scanning WIFI network with my three different WIFI network
Many thanks in advance
#include "WiFi.h"
String get_encryption_type(wifi_auth_mode_t encryptionType) {
switch (encryptionType) {
case (WIFI_AUTH_OPEN):
return "Open";
case (WIFI_AUTH_WEP):
return "WEP";
case (WIFI_AUTH_WPA_PSK):
return "WPA_PSK";
case (WIFI_AUTH_WPA2_PSK):
return "WPA2_PSK";
case (WIFI_AUTH_WPA_WPA2_PSK):
return "WPA_WPA2_PSK";
case (WIFI_AUTH_WPA2_ENTERPRISE):
return "WPA2_ENTERPRISE";
}
}
// ---- begin of what I added
/*
char ssid[] = "Iphone de ben"; // your network SSID (name)
char pass[] = "XXXX1"; // your network password
*/
char ssid[] = "SFR-d078"; // your network SSID (name)
char pass[] = "DEDW3Z"; // your network
//char ssid[] = "Bbox-E69F0626"; // your network SSID (name)
//char pass[] = "NKg5Ad"; // your network
// ---- end of what I added
void setup(){
Serial.begin(115200);
WiFi.mode(WIFI_STA);
}
void loop() {
Serial.println("uPesy WiFi Scan Demo");
Serial.println("[*] Scanning WiFi network");
// WiFi.scanNetworks will return the number of networks found
int n = WiFi.scanNetworks();
Serial.println("[*] Scan done");
if (n == 0) {
Serial.println("[-] No WiFi networks found");
} else {
Serial.println((String)"[+] " + n + " WiFi networks found\n");
for (int i = 0; i < n; ++i) {
// Print SSID, RSSI and WiFi Encryption for each network found
Serial.print(i + 1);
Serial.print(": ");
Serial.print(WiFi.SSID(i));
Serial.print(" (");
Serial.print(WiFi.RSSI(i));
Serial.print(" dB) [");
Serial.print(get_encryption_type(WiFi.encryptionType(i)));
Serial.println("]");
delay(10);
}
}
Serial.println("");
// Wait a bit before scanning again
delay(5000);
}