Control an ESP32 or ESP8266 GPIO pin (LED) directly from a web browser using an asynchronous web server.
The project provides real-time LED control with authentication and WiFi fail-safe protection.
This project demonstrates how to build a lightweight IoT web interface on ESP32/ESP8266 using an asynchronous HTTP server.
It allows authenticated users to toggle a GPIO pin (LED) from any browser connected to the same network.
Designed to be:
- Simple to deploy
- Fast and non-blocking
- Easy to extend for real IoT applications
- Asynchronous web server (non-blocking)
- HTTP Basic Authentication
- Instant LED state update without page reload
- ESP32 and ESP8266 compatible
- WiFi connection timeout protection
- Single
.inofile for easy upload - Minimal hardware requirements
| Component | Pin | Description |
|---|---|---|
| ESP32 Dev Board | GPIO 2 | Built-in LED |
| External LED | GPIO 2 | Optional |
| Resistor | 220Ω | Current limiting |
| Jumper Wires | — | Connections |
Connection:
GPIO 2 → LED → 220Ω resistor → GND
- Arduino IDE (latest recommended)
- ESP32 or ESP8266 board support installed
- Required libraries:
- ESPAsyncWebServer
- AsyncTCP (ESP32) or ESPAsyncTCP (ESP8266)