RO EN

Remote LED control

01/08/2026

I've already told you how many interesting things you can do with an ESP32—and this is just the beginning. Using this project idea, you can control various devices, relays, and more with a simple ESP board. Here, everything is kept simple: it's just an LED controlled from your phone… but it's still pretty cool.

You need to install the ESP32 board package and the WiFi library. I connected the ESP32 to my phone using a hotspot, but it can also be connected directly to a router.
You can find the video on Instagram: here.

In the code, you need to replace SSID with your network name and password with your network password. Once the ESP is connected to the network, a web page will appear that can be accessed by entering the IP address in a browser.
To find the IP address, open the Serial Monitor and you should see something like this:

Now let me explain how we get to this point.

Required components:

  • ESP32

  • LED

  • 220 Ω resistor

  • Jumper wires

  • Breadboard

Connections:

Connect the long leg (anode) of the LED to GPIO 25, and connect the other leg (cathode) to GND through a 220 Ω resistor.


Code:

#include <WiFi.h>

// -------- WiFi --------

const char* ssid = "SSID";

const char* password = "password";

// -------- LED --------

const int ledPin = 25;

WiFiServer server(80);

void setup() {

Serial.begin(115200);

pinMode(ledPin, OUTPUT);

digitalWrite(ledPin, LOW);

// Conectare WiFi

WiFi.begin(ssid, password);

Serial.print("Conectare la WiFi");

while (WiFi.status() != WL_CONNECTED) {

delay(500);

Serial.print(".");

}

Serial.println("\nWiFi conectat!");

Serial.print("IP-ul ESP32 este: ");

Serial.println(WiFi.localIP()); // afișeaza IP-ul in Serial Monitor

server.begin(); // pornește serverul pe portul 80

}

void loop() {

WiFiClient client = server.available(); // asteapta client

if (client) {

String request = client.readStringUntil('\r');

Serial.println("Cerere: " + request);

client.flush();

// Controleaza LED-ul

if (request.indexOf("/on") != -1) {

digitalWrite(ledPin, HIGH);

}

if (request.indexOf("/off") != -1) {

digitalWrite(ledPin, LOW);

}

// Trimite pagina web cu butoane mari

client.println("HTTP/1.1 200 OK");

client.println("Content-Type: text/html");

client.println("Connection: close");

client.println();

client.println("<!DOCTYPE HTML>");

client.println("<html>");

client.println("<head>");

client.println("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"); // responsive mobil

client.println("<style>");

client.println("body { font-family: Arial; text-align: center; font-size: 24px; }");

client.println("button { font-size: 32px; padding: 20px 60px; margin: 20px; border-radius: 15px; }");

client.println("</style>");

client.println("</head>");

client.println("<body>");

client.println("<h1>Control LED / Control LED</h1>");

client.println("<p>Apasa un buton / Press a button</p>");

client.println("<a href=\"/on\"><button>ON</button></a>");

client.println("<a href=\"/off\"><button>OFF</button></a>");

client.println("</body>");

client.println("</html>");

delay(1);

client.stop();

}

}

-