Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:iot-open:espressif_esp8266_scanner [2023/10/10 15:47] ktokarzen:iot-open:espressif_esp8266_scanner [2023/11/23 12:46] (current) pczekalski
Line 1: Line 1:
 +====== ESP8266 Wifi Scanner ======
 +{{:en:iot-open:czapka_b.png?50| General audience classification icon }}{{:en:iot-open:czapka_e.png?50| General audience classification icon }}\\
 +This sketch demonstrates how to scan WiFi networks. ESP8266 is programmed in access point mode. 
 +All found WiFi networks will be printed in the serial monitor window (TTY).
 +
 +<code c >
 +#include "ESP8266WiFi.h"
 +
 +void setup() {
 +  Serial.begin(115200);
 +
 +  // Set WiFi to station mode and disconnect 
 +  // from an 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 a bit before scanning again
 +  delay(5000);
 +}
 +
 +</code>
  
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0