Electronics for Building Things · Lesson 20 · Connectivity

Talking Over the Network (HTTP)

Control and monitor your gadget from any browser in the house.

Now that your ESP32 is on Wi-Fi (Lesson 19), the simplest way to interact with it is the same way you visit a website: HTTP. You'll turn your gadget into a tiny web server you open from your phone.

The one win You understand the request/response model — and how typing your ESP32's address into a browser can flip a relay or show a sensor reading.

Request and response

The web runs on a simple back-and-forth. A client (your browser) sends a request to a server; the server sends back a response. When your ESP32 is the server, you type its IP address (from last lesson) into a browser, and it replies with a web page or a value (Random Nerd Tutorials: ESP32 Web Server).

phone / browser ESP32 GET /on → ← page / value
The browser asks; the ESP32 answers. A URL like /on becomes a command the gadget acts on.

URLs as commands

Here's the neat trick: different URLs trigger different actions. Visit http://192.168.1.42/on and the ESP32 sees a request for /on, turns a relay on, and replies. /off turns it off. /status returns a sensor reading. A little web page with buttons just sends those URLs for you — instant phone control of your relay or any output.

Two roles your ESP32 can play Server (most common): it hosts a page you open to control/monitor it. Client: it makes requests out — e.g. fetching weather data or posting a reading to an online service.
Reach it by name Remembering IP numbers is annoying, and they can change. With mDNS you can give the board a name and open it at something like http://mygadget.local instead.

Where HTTP runs out of road

A web server is perfect for one gadget you check on demand. But it has limits that matter for a whole smart home:

Those limits are exactly what the next protocol — MQTT — is built to solve.

Check yourself

Read this next (primary source) Random Nerd Tutorials — Building an ESP32 Web Server (Beginner's Guide). A full walk-through controlling outputs from a browser.
I'm your teacher — ask me anything. Want a simple phone page to toggle a relay? Tell me what to control and I'll help you map the URLs to actions.

See also: Glossary · Connectivity cheat-sheet · Rules of thumb