Skip to content

A Wi-Fi scanner on the ESP32-S3: finding the right place for the access point

· network, technology, hardware

An ESP32-S3 with a 2.8-inch display measures the Wi-Fi level every five seconds, stores the rows on card and log server, and shows where the access point belongs.

With poor Wi-Fi reception you rarely know where the router should stand and where an access point in between would make sense. “It is bad here” is not a measurement but an impression, and it changes with the time of day and with the number of devices transmitting at the moment.

The scanner takes that decision off your hands. You pick the network on the display and type the password; after that the device writes a measurement row every five seconds. Let it run for a longer period — twenty-four hours and more — and you see how the level really fluctuates at one place, and you can put the access point where it actually helps.

The board

The device is an ESP32-S3 with a 2.8-inch display and touch, sold by several vendors as a finished board (product page at Amazon, advertisement). The board used here is an LCDWiki 2.8inch ESP32-S3, SKU ES3C28P:

Part Value
Module ESP32-S3, 16 MB flash, 8 MB PSRAM
Display 2.8 inch IPS, 240 × 320 pixels, ILI9341V over 4-wire SPI
Touch FT6336G over I2C
Storage microSD over SDMMC, 4 bit
Audio I2S, amplifier and built-in microphone
Power USB or battery, charge level is shown

The board runs from a small battery (battery pack for the board, advertisement) or from USB. The firmware reads the voltage itself; it appears as a number and as a charge level on the display. From 3.5 volts on there is a warning, at 3.3 volts the device would go into deep sleep. For a measurement over twenty-four hours the battery is enough; for longer series the device stays on the power supply.

Two peculiarities of the board cost time on first setup: the panel has no reset pin of its own, RST hangs on the enable of the module. And the colour order is BGR, because the IPS panel otherwise draws with swapped colours.

Operating it on the device

At start the S3 reads its Wi-Fi credentials from storage. If none is reachable, the network selection opens; otherwise the overview is there right away: level, channel, connection time, latency to the router and to the internet, battery voltage.

The network selection lists visible networks sorted by level. A known network appears in green, a tap opens the password field — pre-filled if the network had been entered before. Scanning happens only on a button press or when there is no connection. A scan pauses the device’s own traffic for a few seconds; whoever runs it every second is no longer measuring the network but itself.

The keyboard is drawn by hand: six columns by five rows, 36 × 36 pixels per key, with an extra page for digits and special characters. The ready-made keyboard of the graphics library was too small on the 2.8-inch screen to use without typos. The password stays visible while typing — on a test device in your hand, typos weigh heavier than a glance over your shoulder.

What is measured

One row every five seconds, one file per day, about three megabytes. Each row contains:

Field Meaning
seq, boot, uptime running number, boot counter, seconds since start
epoch time from the network service; 0 while the clock is not set
rssi, ch, bssid level in dBm, channel, address of the access point
gw, inet, dns, tcp ping to the router, to the internet, name resolution, connection setup
loss, jitter share of lost pings, variation of the latency
ssid, ip, heap, wghs network name, own address, free memory, tunnel state
note events, such as a dropped connection

The level alone says little. Only with loss and jitter do you see whether a connection is merely weak or also unreliable — an access point at −70 dBm without loss is more useful than one at −60 dBm with dropouts.

The software behind it

Everything is written with Espressif’s ESP-IDF, the official development environment for these chips, here in version 5.5.5. It is a toolbox, not an editor with a compile button:

  • CMake and Ninja build the project, idf.py is the tool on top: configure, build, flash, follow the log, inspect memory use.
  • The cross compiler translates for the S3’s Xtensa architecture; nothing of it runs on the computer itself.
  • FreeRTOS provides the tasks — separate ones for display, scan, memory card and OTA, so the display does not freeze while a card is being written.
  • lwIP, mbedTLS and wpa_supplicant come along: TCP/IP, encryption, Wi-Fi stack.
  • LVGL 9.4 draws the interface. It is wired up by hand — flush callback, tick from a timer, touch as input device — and not through the ready-made port. One layer less that can break. Drawing happens exclusively from the main task; two tasks on the same widget tree lead to a crash sooner or later.
  • WireGuard and libsodium sit in the tree as source. The private key is created on the device and does not leave it.

NVS: where settings live

A microcontroller has no disk on which a configuration file could sit. The ESP32 instead brings NVS, “non-volatile storage”: a small area in flash holding key-value pairs that survive a restart and a new firmware image.

In practice:

  • Wi-Fi credentials are stored as entries; the scanner remembers up to six, newest first. If the current network is gone, it tries the next one every ten seconds.
  • The WireGuard key lives there — not in the image, not in the log. A new image does not change it.
  • A separate namespace keeps the Wi-Fi data apart from the tunnel data, so cleaning up one does not delete the other.
  • A counter in NVS says after every start which boot this is. Without it, restarts could not be told apart in the measurement rows.

NVS is thus the counterpart to the memory card: the card carries the measurement data, NVS the settings. Both survive a power loss — one as a file, the other as a key-value pair.

The path to the log server

The S3 builds a WireGuard tunnel into the server network. That puts it on the log server without opening a port in whichever Wi-Fi it happens to sit in — the device may stand in a foreign network and still be reachable.

Over that tunnel the device sends its measurement rows itself: every row that goes to the card also goes as a datagram to the syslog input of the server. Sending is an addition, not a replacement — without the tunnel the row stays on the card, and a counter in the status report says how many rows did not make it out.

The tunnel does not start automatically but on a button press. The reason is uncomfortably practical: a misconfigured tunnel that comes up during boot can put the device into a loop it cannot leave without a cable.

Over the tunnel the device is reachable from the server network: overview, journal, diagram and the OTA fetch run over HTTP, and only addresses from our own network and from the tunnel are accepted. From outside, the device is not reachable.

Where the data ends up

On the card the S3 writes its rows, one file per day. The file is closed after every row; a power failure costs at most the last row. A pitfall that cost an evening: the card runs with the FAT driver without support for long file names, i.e. the old 8.3 format. That allows eight characters for the name, three for the extension, separated by the dot — twelve characters including the dot. Letters, digits and a few special characters are allowed; no spaces, no umlauts.

net1031.csv fits (seven plus three), display-20261031.csv does not: the name before the dot has fourteen characters, and the system answers with EINVAL — an error you first look for in the filesystem although it sits in the name.

On the log server the same rows arrive over the tunnel. There an rsyslog input accepts them, a dedicated ruleset writes them into a file, and a template puts the reception timestamp and the source address in front of each row:

module(load="imudp")
input(type="imudp" address="<tunnel address>" port="514" ruleset="netlog")
template(name="netlogRaw" type="string"
         string="%timereported:::date-rfc3339% %fromhost-ip% %rawmsg%\\n")
ruleset(name="netlog") {
    action(type="omfile" file="/var/log/netlog/netlog.log" template="netlogRaw")
}

Without that timestamp a row could later be assigned to no time at all — the device clock is only valid after the first time sync. A timer reads the file every minute and stores the rows additionally in structured form in the journal, so they can be queried by period and level. The file itself is rotated weekly and compressed; old states stay on disk.

Diagram: Wi-Fi level and latency over six hours, with boot changes and loss markers
Six hours from the log: the level in dBm on top, the latency to the internet below, with boot changes and markers for lost pings in between.

From log to diagram

On the server a Python script reads the daily files and draws an SVG. It uses only the standard library — no matplotlib, no Gnuplot, no dependency that breaks on the next system update.

Two lanes over the same time axis: the level on top, the latency to the internet below, logarithmic. Plus vertical lines at boot boundaries, markers for rows with packet loss, and a column with the rating on the right. Gaps are compressed to a fixed width; otherwise a multi-hour outage pushes the actual measurement time to the edge.

For finding a place, that is exactly the evaluation: a spot that fluctuates between −60 and −80 dBm over hours is less suitable than one with a stable level, even if the average looks the same. In the picture above you see it at the two steps — the same transmitter, two places, about 15 dB apart.

The device itself does the same in smaller form: under /chart.svg it serves a diagram of the last 200 values, drawn straight from memory, for a look in between.

OTA: new firmware without a cable

A device mounted somewhere on a wall is not taken down for flashing. The S3 therefore updates itself, over the same tunnel.

The sequence:

  1. On the server lies a manifest, one text line with version number and file name of the image.
  2. The device fetches the manifest, compares the version with its own and loads the image if needed.
  3. It writes into the inactive of the two app areas in flash. The running image stays untouched, an interruption in the middle is harmless.
  4. After the reboot the new image runs. If it does not report itself as ready within 180 seconds, the bootloader switches back to the old version.
  5. Only after that is the new state released and the valid one on the next start.

In practice: an update is a file swap on the server and one call, then the device restarts and runs the new version. No cable, no button, no access to where it is mounted. It is also the reason why a device that is no longer reachable after a restart can become reachable again — the old version is still there.

Checking after an update is part of it: first the version on the console, then the measurement rows of the next minutes, only then the next step.

What went wrong along the way

  • The tunnel crashed as soon as it ran. The cause was a network option in the build that switched on a bridge and took the packets away from the tunnel. Found only because the device wrote its own log.
  • The web page rejected every request, including those from the tunnel: the code compared addresses as IPv4, the operating system delivered them as IPv6 in mapped form.
  • An update did not get through because the share was not yet mounted at boot. The service did not start, and nobody noticed for two days. Since then, after every restart the check is whether the service runs.

Sources

All addresses retrieved on 26 November 2026, each answered HTTP 200.

  1. LCDWiki, 2.8inch ESP32-S3 Display — board, pinout, schematic: https://www.lcdwiki.com/2.8inch_ESP32-S3_Display
  2. Espressif, ESP-IDF 5.5.5 for ESP32-S3 — build, components, tools: https://docs.espressif.com/projects/esp-idf/en/v5.5.5/esp32s3/
  3. Espressif, Wi-Fi driver and scan procedure: https://docs.espressif.com/projects/esp-idf/en/stable/esp32s3/api-guides/wifi.html
  4. Espressif, NVS — non-volatile key-value storage in flash: https://docs.espressif.com/projects/esp-idf/en/stable/esp32s3/api-reference/storage/nvs_flash.html
  5. Espressif, OTA updates at runtime: https://docs.espressif.com/projects/esp-idf/en/stable/esp32s3/api-reference/system/ota.html
  6. LVGL, documentation of the graphics library: https://docs.lvgl.io/master/index.html
  7. rsyslog, manual and imudp input: https://www.rsyslog.com/doc/ and https://www.rsyslog.com/doc/configuration/modules/imudp.html
  8. WireGuard, project page: https://www.wireguard.com/
  9. Espressif, FatFS in ESP-IDF — CONFIG_FATFS_LFN_NONE restricts names to the 8.3 format: https://docs.espressif.com/projects/esp-idf/en/stable/esp32s3/api-reference/storage/fatfs.html

← all posts