sketch_42_Scan_WiFiNetworks   (ESP8266 NodeMCU)

sketch_42_Scan_WiFiNetworks
  /*Es werden alle vom ESP erreichbaren WLAN-Netzwerke (WiFi Networks, WLAN Access Points) gesucht (gescannt). 
    Im Seriellen Monitor wird angezeigt: Anzahl der WLAN-Netzwerke, deren Bezeichnung sowie Signalstaerke.
    Nach 10 Sek wird der Scan wiederholt.
    (Beachte: Baudrate des Seriellen Monitors muss identisch zu derjenigen im Sketch sein). Gewaehlt ist 115200 Baud.*/
  
  #include <ESP8266WiFi.h>
  
  void setup()
  {
    Serial.begin(115200);
      // Set WiFi to station mode and disconnect from an Access Point (AP) if it was previously connected
      WiFi.mode(WIFI_STA);
      WiFi.disconnect();
      delay(100);
      Serial.println("Setup done");
    }
    
    void loop()
    {
      Serial.println("Scan start");
      // WiFi.scanNetworks will return the number of networks found
      int n = WiFi.scanNetworks();      
      Serial.println("Scan done");
      if (n == 0)
        Serial.println("No networks found");
      else
      {
        Serial.print(n);
        Serial.println(" Networks found");
        for (int i = 0; i < n; ++i)
        {
          // Print SSID and RSSI for each network found
          Serial.print(i + 1);
          Serial.print(": ");
          Serial.print(WiFi.SSID(i));
          Serial.print(" (");
          Serial.print(WiFi.RSSI(i));
          Serial.print(")");
          Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*");
          delay(10);
        }
      }
      Serial.println("");
    
      // Wait 5 sec before scanning again
      delay(5000);
    }