m5paper_wifi_scan.ino

M5Stack M5Paper · File : m5paper_wifi_scan.ino · Language : C++ · Use case : Scanner les réseaux Wi-Fi disponibles et afficher le résultat sur l'écran.

Uses the ESP32 WiFi library to list networks and display them on the e-Ink.

Requires including <WiFi.h>. The scan is blocking. Display uses drawString with a reduced font size to fit multiple lines. Call updateDisplay() once after drawing to optimize power.

m5paper_wifi_scan.ino

#include <M5EPD.h>
#include <WiFi.h>

M5EPD m5epd;

void setup() {
  m5epd.begin();
  m5epd.updateBuffer();
  
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  
  int n = WiFi.scanNetworks();
  
  m5epd.drawCentreString("WiFi Scan Results", 480, 50, 4);
  int y = 100;
  for (int i = 0; i < n; ++i) {
    String line = String(i+1) + ": " + WiFi.SSID(i) + " (" + String(WiFi.RSSI(i)) + ")";
    m5epd.drawString(line, 50, y, 2);
    y += 20;
    if (y > 500) break; // Limite de la hauteur de l'écran
  }
  m5epd.updateDisplay();
}

void loop() {}

← Back to the board