ESP32WROOM-32Essidpassantenna3.3 Vsend 240 mAlisten 95-100 mAsleep 20-68 mAHomeNetno IP192.168.1.4201DHCP1WiFi.mode(WIFI_STA);2WiFi.begin(ssid, pass);3while (WiFi.status()4 != WL_CONNECTED)5 delay(500);6Serial.println(WiFi.localIP());1234567891011??M1M2M3M4DORAIP
Back: the ESP32 board (module, antenna, supply, status lamp) and the home router (access point, DHCP server)Front: the setup() card and the Wi-Fi channels 1-11Tokens: settings, status polls, probes, join frames, handshake and DHCP messagesAn ESP32-DevKitC-32E joins the WPA2 network HomeNet. WiFi.begin() only starts the join; the sketch polls WiFi.status() every 500 ms. In the background the driver finds the network (a scan of channels 1 to 11), joins it (authentication and association), proves the password (the 4-way handshake) and gets an address from DHCP (192.168.1.42). Only then is status() WL_CONNECTED. Links drop and come back, and the radio's 240 mA transmit peaks set the size of the supply.

Start the join

  1. Wi-Fi has two roles. An access point (AP), like a home router, runs a network; a station joins one. Line 1 makes our ESP32 a station. Its radio is inside the chip, wired to a small antenna on the module.

Four stages

Online, and staying there

What happens

;; step 1/10 · station
line 1    WiFi.mode(WIFI_STA);
AP        runs the network: the home router
station   joins a network: our ESP32  (STA)
board     ESP32-DevKitC-32E, module ESP32-WROOM-32E
radio     802.11 b/g/n, 2.4 GHz, PCB antenna

The card shows only the join inside setup(). The full sketch includes <WiFi.h>, defines ssid and pass, starts Serial at 115200 baud, and in loop() checks WiFi.status() before using the network. Real firmware also gives the while loop a timeout, so a wrong password cannot hang it forever. In the Arduino core for ESP32, status() becomes WL_CONNECTED only on the got-IP event; the link-up event (STA_CONNECTED) alone does not set it. In ESP-IDF itself it is the application’s job to call esp_wifi_connect() again after a disconnect; the Arduino core does that for you while auto-reconnect is on.