IoT LEDStrip using ESP8266 and Blynk

By snorlaxprime

I have the previous post about how to make a disco light using the individually addressable LEDStrip. This was done using Arduino nano, and I always wonder whether I can make one using ESP8266. The Library that I used for Arduino is not compatible with ESP8266.

Then I stumble across a post that is using Adarfuit library and Blynk. So as part of the learning process, I am documenting my journey on what I have learned.

Step 1. Gather all the required materials

We will need the following:

Please note that the some of the above link is an affiliate link.

Step 2. Build the Circuit

Follow the diagram below to build the circuit.

The concept is quite simple, we use the ESP8266 as the gateway to the internet. ESP8266 will connect to the WiFi and wait for instruction from Blynk. You will need a Blynk app or this excercise. You can download Blynk from Apple Appstore or Google play for Android devices. Blynk hides all the complexity of dealing with the programming the IOT devices.

Step 3. Download and Setup Blynk

Once you have downloaded Blynk, you will need to register if you don’t already have an account.

Follow the instruction on the Blynk website to get started. You will need to:

1.Create a New project once you have register an account as shown in the following picture:

When you create a new project, you will need to provide the name of your project, select the hardware, in this example we are using ESP8266, and the connection is via WiFi. Once you click on “Create Project” button, the project will be created and you will be provided with the unique “Authentication code” that you will need to enter into the Arduino Code.

2. Once you have created the project it is time to add a widget. You will be presented with a blank screen. You can then swipe to the right to open the widget selection screen as shown in the following picture:

Select “zeRGBa” widget and add it to the main screen. We will use this widget to control the LEDStrip. Once you add the widget, it will looks like the second screen above.

3. Then you can configure the connection by clicking on the zeRGBa widget. You will be presented with the following picture:

You would want to select “Merge” on the output as we are using the individually addressable LED WS2812B. If you are using the RGB led, you will use the SPLIT output. Then you will want to select V2 as the output port,as we are connecting the LED Strip via D2 in the circuit diagram in Step 2. Once you have set this up, you can then execute the code later by clicking on the “Triangle” Button. But wait a minute, hold your horses, as we need to upload the code to the ESP8266 first.

Step 4. Upload the code to ESP8266 using Arduino Interface

Now you can open your arduino interface and copy and pas the following code:

#include <Adafruit_NeoPixel.h> 
#include <SPI.h> 
#include <BlynkSimpleEsp8266.h>
#include <ESP8266WiFi.h> 
#define PIN D2
#define NUMPIXELS 30
#define BLYNK_PRINT Serial
 Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
 void setup()
   Blynk.begin("Authentication Token", "SSID", "Password");
 int R = param[0].asInt();
 int G = param[1].asInt();
 int B = param[2].asInt();
 for(int i=0;i<NUMPIXELS;i++){
 pixels.setPixelColor(i, pixels.Color(R,G,B));
 void loop()

A few things to consider, you will need to add the Adafruit library and Blynk library and ESP8266 library if you don’t have them already. The data pin that connects to the LEDStrip is coming from D2, you can change this if you are using other ports. The NUMPIXELS 30 needs to match your LED strip, I have the strip with 30 pixels.

You will also need the “Authentication Token” from the Project, and the “SSID” and “password” for your router. Once you have done this adjustment, you can then upload the code to ESP8266.

Then you can go back to previous step and click on the “Triangle” button. If all goes well, you should be able to slide the circle around to control the colour of your LEDStrip. Note that the LEDStrip can be controlled form anywhere in the world as long as you have internet access. As you can see this hides a lot of the complexity of the code behind the simple user interface.

I hope you enjoy this post. Please subscribe if you like more update on the IoT circuit and drop me a comments if you have any questions.