Electronics for Building Things · Lesson 19 · Connectivity
Getting on Wi-Fi
The first step in making a gadget you can reach from anywhere in the house.
This track is the REPORT arrow from Lesson 18's
SENSE → DECIDE → ACT → REPORT loop — and the reason you chose an ESP32 in the first place. It starts
here: getting your board onto your home network so it can talk to your phone, a server, or Home Assistant.
The one win
You understand how an ESP32 joins your Wi-Fi network and gets an address other devices can reach it at —
and you know the gotchas that trip up every beginner.
Two Wi-Fi modes
Station mode (STA) — the ESP32 joins your existing home Wi-Fi, like your
phone does. This is what you want for home automation.
Access Point mode (AP) — the ESP32 becomes its own little hotspot you
connect to directly. Useful for initial setup (entering Wi-Fi details) or where there's no network.
(It can even do both at once, but start with station mode.)
Set station mode and call WiFi.begin(ssid, password) with your network name and password.
Wait in a short loop until WiFi.status() reports WL_CONNECTED — joining
takes a moment.
Read WiFi.localIP() — the IP address your gadget was given.
The IP address: your gadget's house number
When the ESP32 joins, your router hands it an IP address (e.g.
192.168.1.42) — its address on your local network. Other devices in your house reach it at
that number. (Next lesson, you'll type it into a browser to control the gadget.)
Tip
Router-assigned IPs can change. For something you'll connect to often, set a static IP
(or a DHCP reservation in your router), or give the board a hostname and reach it by name (more in
Lesson 20).
The gotchas that waste hours
Read these now, thank yourself later
2.4 GHz only. The ESP32's Wi-Fi does not work on 5 GHz networks. If it
won't connect, this is the #1 cause — use your 2.4 GHz SSID.
Don't hard-code credentials in shared code. Keep your Wi-Fi name/password in a
separate secrets file you don't commit — especially with your repo public
(like this course!).
Handle dropouts. Wi-Fi disconnects happen; add reconnection logic so your gadget
recovers on its own.
Placement matters. Thick walls and distance weaken the signal; a flaky gadget is
often just far from the router.
I'm your teacher — ask me anything. If your ESP32 won't connect, tell me what you see
— nine times in ten it's the 2.4 GHz issue or a typo in the credentials, and I can help you spot it.