serveur-web.ino
The connected classic: the board serves an HTML page on the local network, two links toggle the LED, and an ADC shows live. No external infrastructure — the server runs inside the board.
Hardware required
An ESP32-S3 board (dual-core Xtensa with vector instructions, Wi-Fi + BLE 5, native USB) such as a DevKitC-1, XIAO or T-Display-S3, powered over USB. 2.4 GHz Wi-Fi access (not enterprise WPA3); optional potentiometer on an ADC.
Wiring
LED on GPIO2 through 330 Ω; potentiometer wiper on GPIO34 (input-only, 3.3 V max) between 3.3 V and GND.
How it works
WiFi.begin joins the access point, WebServer registers routes /, /on, /off and handleClient() serves requests as they come. The refresh tag keeps the page live every 5 s. In the Arduino IDE (esp32 package), select « ESP32S3 Dev Module », enable « USB CDC On Boot », then Upload. Many boards put a WS2812 on GPIO48.
Going further
Add a password (server.authenticate), or publish the same values to an MQTT broker instead of displaying them.
serveur-web.ino
// Serveur web embarque : page de controle LED GPIO2 + etat analogique.
#include <WiFi.h>
#include <WebServer.h>
const char *SSID = "votre-wifi";
const char *CLE = "votre-cle";
const int LED = 2;
WebServer serveur(80);
void page() {
String h = "<h1>ESP32 locale</h1>"
"<p><a href=on>LED ON</a> | <a href=off>LED OFF</a></p>"
"<p>GPIO34 : " + String(analogRead(34)) + "</p>"
"<meta http-equiv=refresh content=5>";
serveur.send(200, "text/html", h);
}
void setup() {
pinMode(LED, OUTPUT);
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(SSID, CLE);
while (WiFi.status() != WL_CONNECTED) { delay(300); Serial.print("."); }
Serial.printf("\nhttp://%s/\n", WiFi.localIP().toString().c_str());
serveur.on("/", page);
serveur.on("/on", []() { digitalWrite(LED, HIGH); page(); });
serveur.on("/off", []() { digitalWrite(LED, LOW); page(); });
serveur.begin();
}
void loop() { serveur.handleClient(); }