0% found this document useful (0 votes)
2K views

LED Using Blynk and ESP8266

This document describes using Blynk and ESP8266 to control LEDs. It discusses setting up the Blynk app dashboard to control LEDs with widgets, connecting the ESP8266 to WiFi, and programming the ESP8266 code to interface with the Blynk app and control LEDs by turning them on and off or changing RGB color values. The code examples show including libraries, entering credentials, defining widgets to control pins, and running the Blynk connection and timers in loop.

Uploaded by

Deepak Kumbhar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

LED Using Blynk and ESP8266

This document describes using Blynk and ESP8266 to control LEDs. It discusses setting up the Blynk app dashboard to control LEDs with widgets, connecting the ESP8266 to WiFi, and programming the ESP8266 code to interface with the Blynk app and control LEDs by turning them on and off or changing RGB color values. The code examples show including libraries, entering credentials, defining widgets to control pins, and running the Blynk connection and timers in loop.

Uploaded by

Deepak Kumbhar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

LED control with Blynk & ESP 8266

Aim: Study of LED control with Blynk and ESP8266

Objective:

1. To study the pin configuration of ESP8266

2. To and study & use of Blynk for LED control

3. To setup the configuration and program to control the four LED’s ON/OFF action using Blynk.

4. To setup the configuration and program to control RGB LED using Blynk

Circuit Diagram/Block diagram:

Fig.a. Four LED circuit Fig.b.Application

https://www.youtube.com/watch?v=BEZrQcjsWT0
Procedure:

LED using Blynk and ESP8266 (Node MCU)

Blynk is an IoT platform with customizable mobile apps, private cloud, rules engine, and device management
analytics dashboard, designed for easy and customizable Internet of Things applications. Designing dashboard
on Blynk App for IoT projects is really easy, you just have to organize buttons, sliders, graphs,
and alternative widgets onto the screen. We can also edit the widgets as per our requirements.
 
With the help of Blynk, the software side gets easier than the hardware. Blynk is perfect for interfacing with
simple projects like monitoring the temperature of your room or turning lights on and off remotely Here, in this
project we are controlling a LED using Blynk App and Esp8266. Earlier we have controlled the LED using
ESP32. So, not only with ESP8266, it’s easy to interface Blynk app with Raspberry Pi, Arduino and other
microcontrollers.
 
Components Required

1. BYNK APP (Download from Play Store)


2. ESP8266 NODE MC

 Blynk App Dashboard Setup for Controlling LED


To control LED with Blynk app, download and install the Blynk app from Google or Apple app store.
Then, if you are new to Blynk app, create a new account by using your Email and password.
 After sign up click on ‘New Project’ to start your project.
 
Now provide your project a name and as blynk app works with diffferent hardware models. Thus opt for your
device from choices.
 Here, we are using ESP8266 node MCU, so I am proceeding with node MCU.
 While selecting your board opt for your association sort whether or not it's Wi-Fi or LAN or USB association.
 After these steps click on ‘Create’ button to form your project.

 
As, the blank project opens, add Widgets to it by clicking on Add button (Plus sign button)
 
Now after this click on ‘Button’ to add a button in your project.

 
Now in button settings provide a name to your button. After assign the pin number to the ‘OUTPUT’. Also,
give names to your On/Off labels.
 
NODE MCU Setup for Blynk App
In your browser search Blynk code generator then open Blynk example browser,
Select your board and example code, as shown below:

 
Open Arduino IDE and select Tools option as shown below:

 
Note: You should have ESP8266 library installed in Arduino IDE.
 
Then copy the example code from the browser as mentioned above and paste in Arduino IDE.
 
Programmig Code Explanation
The complete code for Controlling LED using Blynk App and ESP8266 is given at the end. Include all the
required libraries for ESP8266 and Blynk App in the code, as shown below:

#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

 
Enter the Auth Token in the code, which you can get from the Blynk App or from the mail you have received
from Blynk.

char auth[ ] = "YourAuthToken";


 
To connect with WIFI enter your SSID name and password

char ssid[ ] = "YourNetworkName";


char pass[ ] = "YourPassword";

 
Here, void blinkLedWidget() function is used for switching ON and OFF the LED.

void blinkLedWidget()
{
if (led1.getValue()) {
led1.off();
Serial.println("LED on V1: off");
} else {
led1.on();
Serial.println("LED on V1: on");
}
}

 
In void setup( ) function, we will initialize the baud rate, LED output and will connect the module with the Wi-
Fi using Blynk.begin(auth,ssid,password); function. This function begins the Wi-Fi connection.

void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
timer.setInterval(1000L, blinkLedWidget);
}

 
Testing LED Control using Blynk App and ESP32
Now, copy and paste the complete code into Arduino IDE. Then upload the code into the ESP8266.
Then, open the Blynk App for controlling the LED from the button widget.

 
So we have successfully designed the Blynk App dashboard and controlled the LED through Blynk app
using ESP8266.
Code
Now in programming, first we need to include the libraries 
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[ ] = "YourAuthToken";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[ ] = "YourNetworkName";
char pass[ ] = "YourPassword";
WidgetLED led1(V1);
BlynkTimer timer;
// V1 LED Widget is blinking
void blinkLedWidget()  // function for switching off and on LED
{
  if (led1.getValue()) {
    led1.off();
    Serial.println("LED on V1: off");
  } else {
    led1.on();
    Serial.println("LED on V1: on");
 }
}
void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, blinkLedWidget);
}
//In the loop function include Blynk.run() command.
void loop()
{
  Blynk.run();
  timer.run();
}

Blynk Control RGB LED Colors

Code:-

//Viral Science www.viralsciencecreativity.com www.youtube.com/c/viralscience

//Blynk Control RGB LED


#define BLYNK_PRINT Serial // Comment this out to disable prints and save space

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

char auth[] = "-----------------------------"; //Authentication Code sent by Blynk to Mail ID

void setup()

Serial.begin(9600);

Blynk.begin(auth, "---------", "---------"); //WIFI Name and Password

void loop()

Blynk.run();

You might also like