Scans nearby WiFi networks and displays them sorted by signal strength β RSSI bars, lock icons, channel numbers, and a live countdown to the next scan.
make the esp32 scan for wifi networks and show them on the screen. i want signal strength, whether it's locked, channel number β like a proper wifi analyser
No extra libraries needed β WiFi.h is part of the ESP32 Arduino core. Layout:
| Area | Height | Content |
|---|---|---|
| Header | 48 px | "WiFi Scanner" title, network count, countdown timer |
| Network rows | 38 px each | SSID, RSSI + channel, lock icon, signal bars β up to 7 rows |
Networks sorted by RSSI descending (strongest first). Alternating row background colours for readability. SSID truncated to 15 chars with a ~ suffix if longer.
Signal bars: 5 bars, each 5 px wide, progressively taller (5, 9, 13, 17, 21 px). Filled bars coloured by signal quality; unfilled bars drawn as outlines in grey:
| RSSI range | Bar colour | Bars filled |
|---|---|---|
| β₯ β50 dBm | Green | 5 |
| β50 to β60 | Green | 4 |
| β60 to β70 | Yellow | 3 |
| β70 to β80 | Red | 2 |
| < β80 dBm | Red | 1 |
Lock icon: drawn as a filled rounded rectangle (body) + an open shackle arc + a small keyhole cutout β all in orange (0xFD20) for visibility on any row background.
void drawBars(int x, int y, int rssi) {
int bars = (rssi >= -50) ? 5 : (rssi >= -60) ? 4 :
(rssi >= -70) ? 3 : (rssi >= -80) ? 2 : 1;
uint16_t color = (rssi >= -60) ? COL_GREEN :
(rssi >= -75) ? COL_YELLOW : COL_RED;
for (int i = 0; i < 5; i++) {
int bh = 5 + i * 4;
if (i < bars) tft.fillRect(x+i*7, y+(20-bh), 5, bh, color);
else tft.drawRect(x+i*7, y+(20-bh), 5, bh, COL_GRAY);
}
}
it should keep rescanning automatically, and show me how long until the next scan
Added a 6-second auto-rescan cycle. The header updates every second with a countdown: <6s, <5s, etc. On scan start the header immediately shows "scanningβ¦" and a "Scanningβ¦" overlay fills the network area.
WiFi.scanNetworks() is a blocking call (~1β3 s), so the UI freezes during the scan β that's expected on a single-threaded Arduino sketch. The display returns instantly when the scan completes.
void loop() {
unsigned long now = millis();
if (now >= nextScan) {
doScan(); // blocking, ~1-3s
} else {
static unsigned long lastTick = 0;
if (now - lastTick >= 1000) {
lastTick = now;
drawHeader((int)(nextScan - now)); // update countdown
}
}
}
Wrote flash-sketch-006-wifi-scanner.sh. Only TFT_eSPI and the built-in WiFi.h β no additional library installs needed.
./flash-sketch-006-wifi-scanner.sh
# Sketch uses 27% of flash, 11% of RAM
# Wrote 278528 bytes at 0x00010000 in 3.5 seconds
# Hash of data verified.
# Hard resetting via RTS pin...
# First scan: 14 networks found
# Strongest: MyNetwork (-42 dBm, ch 6, locked)
| File | What it does |
|---|---|
sketches/wifi_scanner/wifi_scanner.ino | WiFi scan display: RSSI bars, lock icons, channel, auto-rescan countdown |
sketches/wifi_scanner/User_Setup.h | TFT_eSPI pin config for FNK0086 |
flash-sketch-006-wifi-scanner.sh | Full compile + flash automation |