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.

esp32-wifiwifi-implementationstation-mode
Radio Remi, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Handle scans, timeouts, retries, and credential recovery.
  • 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.
iotclass.org

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.

Why it matters

The reviewer should still confirm the exact module or variant, because security modes, coexistence behavior, antenna layout, and SDK support can differ across boards.

ESP32 development board with metal-shielded radio module, printed PCB antenna, USB connector, support components, and two rows of header pins
ESP32 development board with metal-shielded radio module, printed PCB antenna, USB connector, support components, and two rows of header pins
iotclass.org

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.
iotclass.org

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.
iotclass.org

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.

Key terms

If data
If data is created during an outage, record whether it is buffered, summarized, dropped, or marked stale.
iotclass.org

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.
iotclass.org

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.
The ESP32 events become useful when they are treated as a release state machine: scanning and authentication are not the same as DHCP, and DHCP is not the same as usable application service.
The ESP32 events become useful when they are treated as a release state machine: scanning and authentication are not the same as DHCP, and DHCP is not the same as usable application service.
iotclass.org

Major section

The 802.11 Association Sequence Beneath the Events (continued)

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.
  • Reading the reason code instead of blindly retrying turns “Wi-Fi will not connect” into a precise fix.
  • The release record should show the failed stage, the corrected key or mode, the retest result, and whether the support state changed from retrying to usable service.
iotclass.org

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.
iotclass.org

Retrieval practice

Recall check 1 of 5

Radio Remi says: answer from memory, then check your reasoning.

Q1An ESP32 reports that it is connected to Wi-Fi, but telemetry never reaches the intended broker. What is the strongest review conclusion?

AThe Wi-Fi implementation is complete because association with the access point succeeded.
BSeparate station-join evidence from usable-service evidence.
CThe firmware should retry faster until the broker accepts telemetry.
DThe issue must be ignored until installed-site validation.
Show answer

Answer: B ESP32 Wi-Fi readiness requires both station join evidence and usable-service evidence.

iotclass.org

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. What is the best review response?

AKeep setup mode available after joining so support staff can reach the device without knowing the normal network credentials.
BBound setup mode by credential state, trigger, timeout, or support action.
CProvision credentials at the factory and omit setup mode to reduce field configuration steps.
DApprove it if the setup network has a friendly name.
Show answer

Answer: B Setup access point behavior should be limited to onboarding or support conditions and should not remain open during normal operation.

iotclass.org

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?

A802.11ac on 5 GHz with 4 spatial streams.
BWi-Fi 6E on the 6 GHz band only.
C802.11 b/g/n on 2.4 GHz, single spatial stream.
DCellular NB-IoT with a built-in SIM.
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.).

iotclass.org

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?

AAfter IP_EVENT_STA_GOT_IP - association
BImmediately on WIFI_EVENT_STA_START, before connecting.
COn WIFI_EVENT_STA_CONNECTED, which guarantees an IP.
DOnly after a manual reboot.
Show answer

Answer: A Layer-2 association precedes DHCP; sockets need the IP from GOT_IP, not just CONNECTED -- STA_CONNECTED does not yet provide a usable IP address.

iotclass.org

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?

AThe 2.4 GHz link is too weak, even though association already completed.
BDHCP has run out of addresses before the station can request a lease.
CThe SSID is hidden, so passive scanning cannot discover the network.
DA key or security-mode problem, such as a wrong PSK or WPA mismatch.
Show answer

Answer: D Reaching association then failing the 4-way handshake points to the key/security stage, which the reason code names.

iotclass.org

Print reference

Answers 1 of 2

Answer key.

  1. B · ESP32 Wi-Fi readiness requires both station join evidence and usable-service evidence.
  2. B · Setup access point behavior should be limited to onboarding or support conditions and should not remain open during normal operation.
  3. 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.).
iotclass.org

Print reference

Answers 2 of 2

Answer key.

  1. A · Layer-2 association precedes DHCP; sockets need the IP from GOT_IP, not just CONNECTED -- STA_CONNECTED does not yet provide a usable IP address.
  2. D · Reaching association then failing the 4-way handshake points to the key/security stage, which the reason code names.
iotclass.org