🛠 Scanner les réseaux Wi-Fi 2,4 GHz
Objectives
Set the Wi-Fi to station mode, scan surrounding networks with WiFi.scanNetworks, display SSID, RSSI, and channel, then lay the foundations for a connection. The Nano ESP32 (NORA-W106 module) supports only Wi-Fi 4 2.4 GHz (802.11 b/g/n).
Hardware
- 1 × Arduino Nano ESP32 + USB-C cable
- A 2.4 GHz access point (a 5 GHz-only router will not be visible)
Complete code
#include <WiFi.h>
void setup {
Serial.begin(115200);
delay(1000);
WiFi.mode(WIFI_STA); // station, pas de point d'accès
Serial.print("Scan en cours...");
int n = WiFi.scanNetworks; // appel bloquant
Serial.printf(" %d réseaux trouvés\n", n);
for (int i = 0; i < n; i++) {
Serial.printf("%2d | %-24s | %4d dBm | canal %2d\n",
i + 1, WiFi.SSID(i).c_str, WiFi.RSSI(i), WiFi.channel(i));
}
WiFi.scanDelete; // libère la mémoire du scan
}
void loop {}
Expected verification
The console lists networks with their RSSI power (typically -40 to -90 dBm) and their channel. The closest network has the least negative RSSI; a scan typically finds around ten networks in an apartment.
Common errors
- Forgetting WiFi.mode(WIFI_STA): the scan may return nothing at all.
- 5 GHz-only router: empty list, the module is 802.11 b/g/n 2.4 GHz only.
- Forgetting WiFi.scanDelete in a repeated scan loop: result memory accumulates.
- Confusing the cores: use the "Arduino ESP32 Boards" package, not the Espressif package, otherwise no driver installs on Windows.
Other tutorials for this board
Code examples for this board
connexion-wifi.inoArduinopoint-acces.inoArduinoble-capteur.inoArduinoneoled-rgb.inoArduinoadc-12bits.inoArduinopreferences.inoArduino