Join Wi-Fi
Wi-Fi Scan
List nearby APs and RSSI. Used for channel choice and provisioning lists.
Join Wi-Fi
Scan networksRSSIprovisioningchannel selection
ESP32 Wi-Fi parts
Official path: examples/wifi/scan
01 Overview
Scan prints SSID, RSSI and auth mode. Provisioning UIs are built on this.
Use when: showing networks before join, or hunting interference.
Skip when: already joined and not changing network.
The scan result can be used to pick the best channel or feed a provisioning list.
ESP32 supports active and passive scans, with configurable dwell time and channel.
Note: scanning briefly occupies the radio and may affect an existing connection.
02 Hardware
- No extra parts: Only the ESP32 module and antenna are needed.
- Antenna placement: Metal near the antenna or obstructions change RSSI readings significantly; measure the full unit.
- Housing effects: A metal enclosure attenuates signals, so scan results differ from a bare module.
- Power: Scanning increases RF power consumption; ensure a stable supply.
- Layout: Keep the antenna area clear of traces and components.
- Reference design: Follow ESP32 hardware design guidelines for antenna matching and layout.
03 Software flow
1. Initialize NVS and Wi-Fi in STA mode.
2. Call esp_wifi_scan_start with desired scan type (active/passive), channel, and max AP count.
3. Wait for scan done event or use blocking API.
4. Get scan results and iterate over AP records, extracting SSID, RSSI, and auth mode.
5. Filter hidden networks (empty SSID) and sort by RSSI descending.
6. Send the list to a provisioning UI via UART or HTTP.
7. Free memory after scan and avoid blocking the main task.
04 Core points
- RSSI is comparative, not a rangefinder. Multipath affects accuracy.
- A scan can interrupt the current link. Schedule scans during idle time.
- Custom work: list protocol for the phone UI, scan window.
- Watch for scan timeouts and memory limits.
- Scan APIs differ across chips; adjust when porting.