Electronics for Building Things · Lesson 20 · Connectivity
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 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).
/on becomes a command the gadget acts on.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.
http://mygadget.local instead.
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.
See also: Glossary · Connectivity cheat-sheet · Rules of thumb