🛠 Scanner les réseaux Wi-Fi 2,4 GHz

Arduino Nano ESP32 · intermediaire · Schéma : IMG-nano-esp32-intermediaire-1-nanoesp32-scan-wifi.svg — La carte scanne les réseaux Wi-Fi 2,4 GHz environnants avec leur puissance RSSI.

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

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

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials