1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

M5StackでWi-Fi Scanner

Last updated at Posted at 2018-02-13

M5StackでWi-Fi Scannerを動かしてみました。

arduino-esp32 の example の WiFiScan を M5STACK の LCDで表示するようにしてみた。。

#include <M5Stack.h>

// the setup routine runs once when M5Stack starts up
void setup(){

    // Initialize the M5Stack object
    M5.begin();

    // LCD display
    M5.Lcd.printf("Wi-Fi SSID Scanner");

    // Set WiFi to station mode and disconnect from an AP if it was previously connected
    WiFi.mode(WIFI_STA);
    WiFi.disconnect();
    delay(100);

}

// the loop routine runs over and over again forever
void loop() {

    // WiFi.scanNetworks will return the number of networks found
    int n = WiFi.scanNetworks();

    M5.Lcd.fillScreen(BLACK);
    M5.Lcd.setCursor(0,0);
    if (n == 0) {
        M5.Lcd.println("no networks found");
    } else {
        M5.Lcd.print(n);
        M5.Lcd.println(" networks found");
        for (int i = 0; i < n; ++i) {
            // Print SSID and RSSI for each network found
            M5.Lcd.print(i + 1);
            M5.Lcd.print(": ");
            M5.Lcd.print(WiFi.SSID(i));
            M5.Lcd.print(" ");
            M5.Lcd.print(WiFi.channel(i));
            M5.Lcd.print("CH");
            M5.Lcd.print(" (");
            M5.Lcd.print(WiFi.RSSI(i));
            M5.Lcd.print(")");
            M5.Lcd.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
            delay(10);
        }
    }

    // Wait a bit before scanning again
    delay(5000);
}

1
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?