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.

中文

连上 Wi-Fi

Wi-Fi Scan 扫网

列出周围热点和信号,用来选信道、做配网列表。

连上 Wi-Fi 扫描附近网络RSSIprovisioningchannel selection ESP32 Wi-Fi parts

官方路径: examples/wifi/scan

01 项目概述

扫描周边 AP,打印 SSID、RSSI、认证类型。配网 App 的列表通常来自这里。

适用: 配网前展示网络、现场干扰排查。

不适用: 已经连上且不需要换网。

扫描结果用于选择最优信道或作为配网列表的数据源。

ESP32 的扫描支持主动和被动模式,可配置扫描时间与信道。

注意:扫描会短暂占用射频,可能影响当前连接。

02 项目硬件描述

  • 无额外器件: 仅需 ESP32 模块及天线。
  • 天线位置: 天线周围金属或遮挡会显著影响 RSSI 读数,需整机实测。
  • 外壳影响: 金属外壳会衰减信号,扫描结果与裸板不同。
  • 供电: 扫描时射频功耗较高,确保电源稳定。
  • 布局: 天线区域避免走线和元器件,保持净空。
  • 参考设计: 天线匹配和布局参考 ESP32 硬件设计指南。

03 项目软件流程描述

1. 初始化 NVS 和 Wi-Fi,设置为 STA 模式。

2. 调用 esp_wifi_scan_start,配置扫描类型(主动/被动)、信道和最大 AP 数。

3. 等待扫描完成事件,或使用阻塞 API。

4. 获取扫描结果,遍历 AP 记录,提取 SSID、RSSI、认证模式。

5. 过滤隐藏网络(SSID 为空),按 RSSI 降序排序。

6. 将列表通过 UART 或 HTTP 传给配网 UI。

7. 扫描完成后释放内存,避免阻塞主任务。

04 项目核心点

  • RSSI 只能比较,不能当距离计。 受环境多径影响。
  • 扫描会打断当前连接。 已在线产品要选空闲时扫。
  • 可定制: 配网列表 UI 协议、扫描窗口。
  • 注意扫描超时和内存限制。
  • 不同芯片的扫描 API 有差异,移植需调整。