πŸ“‘ ESP32-S3 Β· Sketch 006

WiFi Network Scanner
with Signal Bars

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.

Live Scanning
πŸ“Ά RSSI Signal Bars
πŸ”’ Encryption Detection
πŸ€– Claude Sonnet 4.6
Session Transcript
Building the WiFi Scanner
Step 1 Β· Request
πŸ‘€
Richard

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

✦
Claude

No extra libraries needed β€” WiFi.h is part of the ESP32 Arduino core. Layout:

AreaHeightContent
Header48 px"WiFi Scanner" title, network count, countdown timer
Network rows38 px eachSSID, 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.

Step 2 Β· Signal Bars & Lock Icon
✦
Claude

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 rangeBar colourBars filled
β‰₯ βˆ’50 dBmGreen5
βˆ’50 to βˆ’60Green4
βˆ’60 to βˆ’70Yellow3
βˆ’70 to βˆ’80Red2
< βˆ’80 dBmRed1

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);
  }
}
Step 3 Β· Auto-Rescan & Countdown
πŸ‘€
Richard

it should keep rescanning automatically, and show me how long until the next scan

✦
Claude

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
    }
  }
}
6s rescan interval Countdown in header Sorted by RSSI each scan
Step 4 Β· Flash
✦
Claude

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)
βœ“ Compiled β€” 27% flash βœ“ Flashed successfully Networks listed by signal strength
Session Summary
✦
Claude β€” What We Built
FileWhat it does
sketches/wifi_scanner/wifi_scanner.inoWiFi scan display: RSSI bars, lock icons, channel, auto-rescan countdown
sketches/wifi_scanner/User_Setup.hTFT_eSPI pin config for FNK0086
flash-sketch-006-wifi-scanner.shFull compile + flash automation