Build a Simple ESP32 Web Server with Arduino IDE

Engineering illustration: Build a Simple ESP32 Web Server with Arduino IDE

This project builds a simple web server on an ESP32 board to remotely control two LEDs via HTTP requests, a foundational example showing how servers work on IoT controllers.

Components needed

An ESP32 board, two LEDs with their resistors, and connecting wires.

Wiring it up

Each LED connects to its own GPIO pin through a protective resistor (pins 4 and 5 in this project).

Two operating modes

The server can run in two different modes: Access Point mode, where the board creates its own WiFi network that up to five devices can connect to directly with no existing router needed, or Station mode, where the board connects to an existing WiFi network and gets an IP address from the router to serve content across the entire local network.

How it works

The code relies on two libraries: WiFi.h to manage wireless connectivity in either mode, and WebServer.h to handle HTTP requests and serve web pages. The code defines specific URL routes that trigger particular functions when requested; when a user visits a path like /led1on, the board receives the request and runs the matching function (turning the corresponding LED on or off), then returns an updated HTML page showing the devices' current state. The web interface provides clickable buttons for real-time control of the outputs.

You can find ESP32 boards and LEDs at Juthour Tech.

Leave your comment

*
*
Only registered users can leave comments.