ESP8266 / ESP32 Сканер WIFI сетей

#ifdef ESP8266
#include <ESP8266WiFi.h>
#elif defined(ESP32)
#include <WiFi.h>
#else
#error "ESP8266 or ESP32 board strondly required for complie"
#endif
 
void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);
}
 
void loop() {
  int n = WiFi.scanNetworks();
  Serial.print("Found networks: ");
  Serial.println(n);
  for (int i=0; i<n; i++) {
    Serial.print(i+1);
    Serial.print(": ");
    Serial.print(WiFi.SSID(i));
    Serial.print(" (");
    Serial.print(WiFi.RSSI(i));
    Serial.println(")");
    delay(10);
  }
  Serial.println();
  delay(10000);
}