How to control RGB LED bulb using ESP8266 and Blynk app

How to control RGB LED bulb using ESP8266 and Blynk app

Hello, welcome back. Today we are going to learn how to control an RGB LED bulb using the Nodemcu ESP8266 board and the Blynk app. Also, this project belongs to IoT technology. So use the knowledge in this tutorial for your future projects. OK, we will learn this tutorial step by step.

What is an RGB LED?

This bulb is also a standard LED bulb but includes the three main colors R (Red), G (Green), and B (Blue). Also, we can light up these colors one by one. A typical LED bulb has two pins, but these LEDs have four pins. Here we can identify the three pins as the three-color anode (+) pins and the other pin as the Cathode (-) pin. Also, the cathode (-) pin is slightly longer than the other pins. So we can easily recognize it.

How to control RGB LED bulb using ESP8266 and Blynk app

How does this project work?

When the Nodemcu board is powered on, the Nodemcu board connects to the Blynk cloud through the internet. Afterward, when the slider widget values are changed, these values are received by the Nodemcu board over the Blynk cloud. Then, the RGB LED bulb colors change one by one. We can do this as we like.

OK, let’s do this project step by step. For that, the required components are given below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Firstly, identify these components.

Nodemcu ESP8266 board

RGB LED bulb

180-ohm resistor

Breadboard

Jumper wires

Step 2

Secondly, connect these components. To do this, use the circuit diagram below.How to control RGB LED bulb using ESP8266 and Blynk app

Step 3

Thirdly, let’s set up the Blynk app. For that, use the steps below.

  • First, download and install the Blynk app on your phone. Then, sign up using your Gmail. Next, click the new project button.
  • How to control RGB LED bulb using ESP8266 and Blynk app
  • Now, enter the project name. After, select board type and connection type. Then click the “confirm” button.
  • How to control RGB LED bulb using ESP8266 and Blynk app
  • OK, now you can see the empty project interface. Then click on the “+” icon in the corner.
    How to control RGB LED bulb using ESP8266 and Blynk app
  • Next, add the three slider widgets to the interface and customize them to your liking.How to control RGB LED bulb using ESP8266 and Blynk app

  • Now, click on the slider one by one and change the slider name to your liking. Also, set the pins to D0, D1, and D2. Then, set the output value from 0 to 255.

Step 4

OK, let’s create the program for this project. It is as follows.

/*RGB LED with Nodemcu board.
  created by the SriTu Hobby team.
  Read the code below and use it for any of your creations.
  
Home Page
*/ #define BLYNK_PRINT Serial #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> char auth[] = "";//Enter your Auth token char ssid[] = "";//Enter your WIFI name char pass[] = "";//Enter your WIFI password void setup() { pinMode(D0, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); Blynk.begin(auth, ssid, pass); } void loop() { Blynk.run(); }

Code explanation

First, includes WIFI and Blynk libraries.

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

Next, enter your WIFI connection details and Blynk auth token.

char auth[] = "rP7PvKDHMmXFU7GAEL5q-W9Xh4YrI3Ly";//Enter your Auth token
char ssid[] = "Lakshan 4G";//Enter your WIFI name
char pass[] = "1234";//Enter your WIFI password

In the setup function, the RGB LED pins are set as output pins. Also, the Blynk app connection has been started.

void setup() {
pinMode(D0, OUTPUT);
pinMode(D1, OUTPUT);
pinMode(D2, OUTPUT);
Blynk.begin(auth, ssid, pass);
}

In the loop function, the blink application is activated.

void loop() {
Blynk.run();
}

Step 5

Lastly, select the board and port. After, upload this code to the Nodemcu board.

How to control RGB LED bulb using ESP8266 and Blynk app

Now, run the Blynk app and change the slider values. Ok, enjoy this project. The full video guide is given below. So, we will meet in the next tutorial. Have a good day.

How to control RGB LED bulb using ESP8266 and Blynk app

How to control RGB LED bulb using ESP8266 and Blynk app

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *