pdf-icon

Arduino Quick Start

2. Devices & Examples

DinMeter Wi‑Fi Information Retrieval

DinMeter Wi‑Fi related API and example program。

Example

cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#include <M5Unified.h>
#include <WiFi.h>
void setup() {
// Initialize M5Unified
auto cfg = M5.config();
M5.begin(cfg);
M5.Display.fillScreen(TFT_BLACK);
// Set text properties
M5.Display.setTextSize(1);
M5.Display.setTextColor(TFT_WHITE, TFT_BLACK);
// Scan Wi‑Fi
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
int n = WiFi.scanNetworks();
// Print results on the DinMeter screen
M5.Display.setCursor(0, 0);
M5.Display.printf("Found %d networks\n\n", n);
for (int i = 0; i < n; i++) {
M5.Display.printf("%2d: %s\n (%d dBm)\n\n",
i + 1,
WiFi.SSID(i).c_str(),
WiFi.RSSI(i));
delay(50);
}
}
void loop() {
M5.update();
// Place periodic refresh here if needed
}

After uploading, press the Reset button to see the following effect:

On This Page