Turn a $5 ESP32 microcontroller into a web server that you control from your phone's browser. Toggle LEDs, read sensors, and build a smart home dashboard — all running on a chip smaller than your thumb. Step by step, line by line, fully commented code.
A web server is a program that listens for requests from web browsers and sends back web pages. When you visit google.com, a Google server sends you a web page. In this project, YOUR ESP32 will do the same thing — but on your local Wi-Fi network.
You'll open your phone's browser, type the ESP32's IP address (like 192.168.1.42) ja näe veebilehte, mida SERVEERIB sinu tilluke kiip. Lehel on nupud LED-ide juhtimiseks, andurite näitude kuvamiseks ja muuks — kõik reaalajas!
1. Your browser sends a request → "Hey server, give me the page at /"
2. The server processes the request → "They want the homepage, let me build it"
3. The server sends a response → an HTML page with buttons and data
4. Your browser renders the HTML → you see a beautiful page with controls!
This is the same process that powers EVERY website on Earth — and your ESP32 will do it.
ESP32-WROOM-32 or ESP32-S3
Micro-USB või USB-C (oleneb plaadist)
Any color — red, green, blue
Üks iga LED-i kohta nende kaitsmiseks
Temperature + humidity sensor
For connecting everything
For Project 1, you ONLY need the ESP32 board + USB cable — the ESP32 has a built-in LED! You can start coding immediately without buying any extra components. Add LEDs and sensors for Projects 2 and 3.
1. Download Arduino IDE from arduino.cc/en/software (tasuta, avatud lähtekoodiga)
2. Ava Arduino IDE → mine File → Preferences
3. In "Additional Board Manager URLs", paste this URL:
4. Go to Tools → Board → Boards Manager → Search "ESP32" → Install "esp32 by Espressif Systems"
5. Connect your ESP32 via USB → Go to Tools → Board → Select "ESP32 Dev Module"
6. Go to Tools → Port → Select the COM port (e.g., COM3 on Windows, /dev/ttyUSB0 on Linux)
You may need to add yourself to the dialout group: sudo usermod -a -G dialout $USER then log out and back in. This gives permission to access the USB serial port.
Your first web server — no extra hardware needed!
The ESP32 connects to your Wi-Fi, starts a web server, and serves a page with Sisse/välja nupud. Nupule klõpsates saadab brauser ESP32-le päringu, mis lülitab sisseehitatud LED-i sisse või välja. Näed tulemust kohe — telefonist või mis tahes samas Wi-Fi-võrgus olevast seadmest!
1. Change "YOUR_WIFI_NAME" ja "YOUR_WIFI_PASSWORD" to your real Wi-Fi
2. Click the Upload button (nool →) Arduino IDE-s
3. Ava Tools → Serial Monitor (määra kiiruseks 115200 boodi)
4. Wait for the message: "📡 IP Address: 192.168.1.XX"
5. Ava telefonis brauser ja sisesta see IP-aadress!
6. 🎉 You see your web page! Click the buttons — the LED responds!
You just built a web server on a $5 chip! Your phone is talking to a microcontroller through Wi-Fi and HTTP — the same protocol that powers the entire World Wide Web. This is real IoT (Internet of Things) engineering!
Nüüd, kui see töötab, proovi neid muudatusi:
#0f172a (tumesinine) või #064e3b (tumeroheline)for loop with delay())Control red, green, and blue LEDs independently!
ESP32 LEDs
┌──────────┐
│ │
│ GPIO 26 ├─────[220Ω]────🔴 Red LED──┐
│ │ │
│ GPIO 27 ├─────[220Ω]────🟢 Green LED─┤
│ │ │
│ GPIO 14 ├─────[220Ω]────🔵 Blue LED──┤
│ │ │
│ GND ├──────────────────────────────┘
│ │ (all LED negatives
└──────────┘ share ground)
LEDs are hungry — they'll try to draw too much current and burn out. The resistor limits current to a safe level (~15mA). Kasuta iga LED-iga alati takistit! Without it, you'll destroy the LED and possibly damage the ESP32 pin.
/all)analogWrite() või ledcWrite() on ESP32)Reaalajas andurite juhtpaneel automaatse värskendusega!
ESP32 DHT11
┌──────────┐ ┌─────┐
│ │ │ │
│ 3.3V ├────┤ VCC │ (Power)
│ │ │ │
│ GPIO 4 ├────┤ DATA│ (Signal)
│ │ │ │
│ GND ├────┤ GND │ (Ground)
│ │ │ │
└──────────┘ └─────┘
Note: Add a 10kΩ pull-up resistor between DATA and VCC
(some DHT11 modules have it built-in)
In Arduino IDE: Sketch → Include Library → Manage Libraries → Search "DHT sensor library" by Adafruit → Install. Also install "Adafruit Unified Sensor" when prompted.
int visits = 0; ja visits++ in loop)<div> barsBrowsers speak HTTP (HyperText Transfer Protocol). A request like GET /on HTTP/1.1 means "give me the page at /on." The server responds with 200 OK + HTML-sisu. See on kogu veebi alus — ja sinu ESP32 räägib nüüd seda keelt!
The ESP32 connects to your router, gets an IP address (like 192.168.1.42), and listens on port 80. When your phone sends a request to that IP, the router forwards it to the ESP32. This is networking in action.
GPIO pins can be set as OUTPUT (send voltage to control LEDs, motors, relays) or INPUT (read sensors, buttons). digitalWrite(pin, HIGH) sends 3.3V. digitalRead(pin) reads the voltage. This is how software controls the physical world.
The web page your ESP32 sends is real HTML + CSS — the same technology behind every website. You're building full-stack IoT: hardware (ESP32 + sensors) + backend (C++ web server) + frontend (HTML/CSS page). That's 3 skill domains in one project!
Your phone is the client (küsib lehti). Sinu ESP32 on server (saadab lehti ja täidab käske). Sama arhitektuur toetab Netflixi, Google’it, pangarakendusi ja kõike muud veebis.
The WiFiServer we used is basic. For real projects, use the ESPAsyncWebServer library — it handles multiple clients simultaneously, supports WebSockets (real-time updates without page refresh), file serving from SPIFFS/LittleFS, and template processing. It's what professional IoT products use.
Instead of reloading the page to update sensor data, use JavaScript fetch() to request data from the ESP32 in the background and update the page dynamically. The dashboard updates live without flickering!
Pane ESP32 tööle koos Home Assistant (avatud lähtekoodiga koduautomaatika), kasutades ESPHome — a YAML-based firmware that turns ESP32 into smart home sensors and controllers without writing C++ code.
Want to access your dashboard from outside your home? Don't use port forwarding! Install Tailscale on a Raspberry Pi on the same network — now you can access your ESP32 dashboard from anywhere through an encrypted tunnel.
Send sensor readings to InfluxDB (aegridade andmebaas) ja visualiseeri neid tööriistaga Grafana dashboards — see weeks of temperature history, humidity trends, and alerts. All open source.
You built a real web server on a chip smaller than your thumb. You learned HTTP, Wi-Fi networking, GPIO control, HTML, and client-server architecture — all in one project. These are the same skills used by IoT engineers at companies like Tesla, Philips Hue, and Ring. The difference? They had expensive equipment. You did it for $5.
«وَأَلَنَّا لَهُ الْحَدِيدَ»
Tilluke ränikiip — meie ajastu pehmendatud raud. Teadmiste ja koodiga andsid sellele võime serveerida veebilehti, juhtida valgust ning mõõta temperatuuri. Tehnoloogia pole maagia — see on sihipäraselt rakendatud teadmine. ✨