Wi-Fi & 802.11 · Study deck
ESP32 Wi-Fi: Provisioning and Recovery Workflows
A field device needs a safe path when its saved network no longer exists.
Radio Remi is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Handle scans, timeouts, retries, and credential recovery.
- Explain: The ESP32 is a low-cost microcontroller family with integrated Wi-Fi.
- Explain: Its rate ceiling is far below a laptop's, but that is normally acceptable for telemetry, commands, setup pages, and small maintenance transfers.
- Explain: A sensor may need one acknowledged MQTT publish, a maintenance tool may need a local controller command, and a setup page may need a bounded onboarding window.
Major section
The ESP32 Wi-Fi Radio and Its Modes
The ESP32 is a low-cost microcontroller family with integrated Wi-Fi.
- A classic ESP32 design uses an 802.11 b/g/n radio on the 2.4 GHz band, a single spatial stream, and 20/40 MHz channels.
- For review purposes, do not treat an example sketch as the implementation.

Major section
The ESP32 Wi-Fi Radio and Its Modes (continued)
Its rate ceiling is far below a laptop's, but that is normally acceptable for telemetry, commands, setup pages, and small maintenance transfers.
- Choosing the mode is the first decision in any ESP32 Wi-Fi project, but the mode choice is only the start.
- A usable implementation also needs a state model for scanning, joining, address assignment, service readiness, outage, retry, setup, reset, and stopped behavior.
- The basic question is whether the firmware can prove the specific service path it claims to support.
- In each case the evidence should separate radio join, network address, application reachability, credential handling, and recovery.
Major section
The ESP32 Wi-Fi Radio and Its Modes (continued)
A sensor may need one acknowledged MQTT publish, a maintenance tool may need a local controller command, and a setup page may need a bounded onboarding window.
- That separation keeps a serial log that says "connected" from being mistaken for a release decision.
- The record should name the firmware build, SDK path, board, antenna, test access point, and service endpoint.
- The reviewer should still confirm the exact module or variant, because security modes, coexistence behavior, antenna layout, and SDK support can differ across boards.
Major section
The Event-Driven Connection Flow
The critical subtlety: STA_CONNECTED means the radio associated, but the device has no usable IP yet.
- Application sockets must wait for IP_EVENT_STA_GOT_IP.
- Opening a socket on connection rather than on got-IP is a classic beginner bug.
- A practitioner implementation should also put policy around those events.
- Provisioning needs the same discipline.
Major section
The Event-Driven Connection Flow (continued)
If data is created during an outage, record whether it is buffered, summarized, dropped, or marked stale.
- A setup access point should start only under a defined condition such as missing credentials, a physical reset gesture, or an explicit support command.
- It should close after onboarding or timeout, and it should leave a clear failure state when credentials are wrong.
- Worked example: A firmware opens an MQTT socket inside the STA_CONNECTED handler and it fails intermittently.
Major section
The 802.11 Association Sequence Beneath the Events
A wrong password fails at the 4-way handshake, a hidden SSID needs an active probe, and weak signal can produce repeated association timeouts.
- The state machine also protects the rest of the firmware.
- Sensors, actuators, watchdogs, local storage, and user feedback should not freeze while Wi-Fi retries.
- A clean implementation records the last network stage, the disconnect reason, retry count, next retry time, and whether application traffic is allowed.
- That evidence lets a reviewer distinguish a radio problem from a DHCP problem, a DNS problem, an authorization problem, or a broker outage.
Deck summary
Key takeaways
The ESP32 is a low-cost microcontroller family with integrated Wi-Fi.
- Its rate ceiling is far below a laptop's, but that is normally acceptable for telemetry, commands, setup pages, and small maintenance transfers.
- A sensor may need one acknowledged MQTT publish, a maintenance tool may need a local controller command, and a setup page may need a bounded onboarding window.
- The critical subtlety: STA_CONNECTED means the radio associated, but the device has no usable IP yet.
- If data is created during an outage, record whether it is buffered, summarized, dropped, or marked stale.
Retrieval practice
Recall check 1 of 5

Radio Remi says: answer from memory, then check your reasoning.
Q1What does the Wi-Fi connection state establish about broker delivery?
Show answer
Answer: B ESP32 Wi-Fi readiness requires both station join evidence and usable-service evidence.
Retrieval practice
Recall check 2 of 5

Radio Remi says: answer from memory, then check your reasoning.
Q2A device starts a setup access point on every boot and leaves it running after it joins the normal network. How should the setup access point behave after normal network connection?
Show answer
Answer: B Setup access point behavior should be limited to onboarding or support conditions and should not remain open during normal operation.
Retrieval practice
Recall check 3 of 5

Radio Remi says: answer from memory, then check your reasoning.
Q3Which Wi-Fi capabilities does a classic ESP32 provide?
Show answer
Answer: C The ESP32 is a 2.4 GHz b/g/n single-stream radio with STA, AP, and combined modes. (Also: usable as station, SoftAP, or both.).
Retrieval practice
Recall check 4 of 5

Radio Remi says: answer from memory, then check your reasoning.
Q4On an ESP32 station, when should application sockets be opened?
Show answer
Answer: A Layer-2 association precedes IP readiness; sockets need the address confirmed by GOT_IP, not just CONNECTED.
Retrieval practice
Recall check 5 of 5

Radio Remi says: answer from memory, then check your reasoning.
Q5An ESP32 associates successfully but then disconnects with a 4-way-handshake-timeout reason code. What does that indicate?
Show answer
Answer: D The timeout names the failed handshake stage, not a unique root cause; keys, mode, RF loss and AP behavior need checking.
Print reference
Answers 1 of 2
Answer key.
- D · ESP32 Wi-Fi readiness requires both station join evidence and usable-service evidence.
- D · Setup access point behavior should be limited to onboarding or support conditions and should not remain open during normal operation.
- A · The ESP32 is a 2.4 GHz b/g/n single-stream radio with STA, AP, and combined modes. (Also: usable as station, SoftAP, or both.).
- C · Layer-2 association precedes IP readiness; sockets need the address confirmed by GOT_IP, not just CONNECTED.
Print reference
Answers 2 of 2
Answer key.
- C · The timeout names the failed handshake stage, not a unique root cause; keys, mode, RF loss and AP behavior need checking.