IoT Made Easy: ESP8266 + Blynk App to Control LED Remotely

by dziubym in Circuits > Arduino

335 Views, 3 Favorites, 0 Comments

IoT Made Easy: ESP8266 + Blynk App to Control LED Remotely

on.png

Want to control an LED from your smartphone—even when you're halfway around the world—with zero mobile app coding? In this project, you'll learn to do exactly that using the ESP8266 microcontroller and the Blynk IoT platform.

This beginner-friendly guide will walk you through every step to connect your microcontroller to the cloud and control an LED using the Blynk app on your phone.

📺 Prefer video tutorials?

You can follow this project step-by-step on YouTube:

  1. ▶️ Remote LED Control with Blynk App & ESP8266: https://www.youtube.com/watch?v=NDUa-hrw1JA


Supplies

components.png
  1. ESP8266 board (e.g., NodeMCU or Wemos D1 Mini)
  2. LED with built-in resistor (or use a 220Ω resistor)
  3. Breadboard and jumper wires
  4. Micro USB cable
  5. Smartphone (iOS or Android)
  6. Arduino IDE installed
  7. Working Wi-Fi network

How It Works – the Concept Behind the Project

DiagramBkynk.png

What Happens Behind the Scenes:

  1. The Blynk app sends an ON/OFF command (0 or 1) via a button widget linked to Virtual Pin V0.
  2. This command goes to the Blynk Cloud, even over mobile networks.
  3. The ESP8266, connected via your Wi-Fi router, receives the signal from the cloud.
  4. The ESP8266 runs code that listens on V0, and toggles the LED connected to digital pin D2 accordingly.
💡 Earlier, we used Virtual Pin V2 in a test setup. But in the final project, everything runs through V0

Install the Blynk IoT App

Blynk_app.png
  1. Download the Blynk IoT app from the App Store or Google Play.
  2. Sign up or log in with your email.
  3. You're now ready to build your device interface.

Create a New Blynk Template and Device

new device.png
new device1.png
new device2.png
new device3.png
new device4.png
new device5.png
new device6.png

For this project, all configuration — including templates, datastreams, and device creation — is done through the Blynk.Cloud web interface, not the mobile app.

🔗 Here’s how to do it:

  1. Visit https://blynk.cloud and log in with the same account you use on the mobile app.
  2. Click on Templates and then + New Template.
  3. Name it something like "LED Control"
  4. Select Hardware: ESP8266
  5. Select Connection Type: Wi-Fi
  6. After creating the template, go to the Datastreams tab inside the template.
  7. Add a new datastream:
  8. Virtual Pin: V0
  9. Name: LED
  10. Type: Integer
  11. Min/Max: 0 and 1
  12. (Optional) You can skip web dashboard customization since you'll only use the mobile app interface.
  13. Now click Devices > + New Device and choose From Template.
  14. Select the template you just created.
  15. Give the device a name or use the default one.
  16. After creating the device, copy the credentials:
  17. Template ID
  18. Template Name
  19. Auth Token
📝 You’ll need these credentials when writing the Arduino code in the next step.


Build Your Mobile Dashboard

dashboard`.png
Add.png
button.png
button1.png
Button2.png
  1. Open your device in the Blynk mobile app.
  2. Tap the "+" to add a Button widget.
  3. Assign it to V0, set it as a switch (latching), and label it “LED ON/OFF”.
  4. That’s it — no other widgets needed.

🎥 Watch the full video tutorial for a step-by-step demonstration of the entire build and setup process.

Write and Upload the Arduino Code

This code connects your ESP8266 to Wi-Fi and the Blynk Cloud, then listens for changes on Virtual Pin V0 to turn an LED ON or OFF.

#define BLYNK_TEMPLATE_ID "Your_Template_ID"
#define BLYNK_TEMPLATE_NAME "Your_Template_Name"
#define BLYNK_AUTH_TOKEN "Your_Auth_Token"
  1. These lines hold your project credentials from Blynk.Cloud.
  2. They're used to authenticate and link your device to the correct template.

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
  1. Includes the required libraries for Wi-Fi and Blynk functions on the ESP8266.
char ssid[] = "YourWiFiSSID";
char pass[] = "YourWiFiPassword";
  1. Your Wi-Fi network name and password to connect the ESP8266 to the internet.

int ledPin = D2;
  1. Sets D2 as the digital pin connected to the LED.

BLYNK_WRITE(V0) {
int value = param.asInt();
digitalWrite(ledPin, value);
}
  1. This function is triggered whenever the Blynk app sends a value to Virtual Pin V0 (via the button).
  2. If value is 1, the LED turns ON; if 0, it turns OFF.

void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW); // Start with LED OFF
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
  1. Prepares the LED pin as an output and connects the ESP8266 to the Blynk Cloud via Wi-Fi.

void loop() {
Blynk.run();
}
  1. Keeps the device connected and responsive to the Blynk app by continuously running the Blynk process.


Power Up and Test

off_led.png
on_led.png
  1. Plug in your ESP8266.
  2. Open the Blynk app.
  3. Tap the button — the LED should instantly turn on or off!

Control It From Anywhere

wifi.png

To test remote access:

  1. Turn off Wi-Fi on your phone (switch to mobile data).
  2. Open the Blynk app and toggle the button again.
  3. The LED still responds — proving it's working over the internet!

No router changes, port forwarding, or headaches required.

🎉 Conclusion

You’ve now built a fully functional cloud-connected LED control system using the ESP8266 and Blynk — no app coding, no local network limits. This same method can be expanded to control relays, monitor sensors, and automate home devices from anywhere on the planet.

Stay tuned for future projects—and happy tinkering!


Enjoyed this project? Consider buying me a coffee on Ko-fi!