Submit

04 / 20

Use Wi-Fi

A tiny HTTP server lets a virtual phone switch an LED.

Run this experiment →
ESP32 teaching illustration with module, GPIO headers and lesson components

Why it’s here

Connect the simulated network, then tap the phone toggle.

How it works

A tiny HTTP server lets a virtual phone switch an LED. No. Network controls model connection state and HTTP requests locally. The hardware sketch uses WiFi and WebServer. This guided model targets the original ESP32 and Arduino-ESP32 3.x; radio, acoustics, loads and mechanics are simplified.

Try it

  1. Open this experiment
  2. Connect the simulated network, then tap the phone toggle.

Connections

  • 2.4 GHz — Wi-Fi STA + HTTP /toggle
  • GPIO 2 — LED through resistor

Example sketch

#include <WiFi.h>
#include <WebServer.h>
WebServer server(80);
bool lightOn = false;

void setup() {
  pinMode(2, OUTPUT);
  WiFi.begin("YOUR_SSID", "YOUR_PASSWORD");
  while (WiFi.status() != WL_CONNECTED) delay(250);
  server.on("/", []() { server.send(200, "text/html", "<a href='/toggle'>Toggle LED</a>"); });
  server.on("/toggle", []() {
    lightOn = !lightOn; digitalWrite(2, lightOn);
    server.send(200, "text/plain", lightOn ? "ON" : "OFF");
  });
  server.begin();
}

void loop() {
  server.handleClient();
}

Check your understanding

Does this page connect to my home router?

Show the answer

No. Network controls model connection state and HTTP requests locally. The hardware sketch uses WiFi and WebServer.

Sources

Arduino-ESP32 ↗ · GPIO reference ↗

MAKE A THOUGHTFUL CHOICE

Your shortlist, side by side.

Pricing models are indicative. Check each official website for current plans and limits.