You are currently viewing Internet Controlled Christmas Tree Lights LED Strip using NodeMCU [WS2812 Neopixel]

Internet Controlled Christmas Tree Lights LED Strip using NodeMCU [WS2812 Neopixel]

SuperKitz.com ​Project Manual

Internet Controlled Christmas Tree Lights LED Strip using NodeMCU [WS2812 Neopixel] DIY Kit

Using Arduino Nano and LED

This project allows you to create some cool light effects with WS2812 Neopixel  LEDs. Using simple FAST commands and fundamentals, we can design a low cost LED dancing lights especially if you are not able to program a simple Arduino.

LEDs are used in almost every decorative lightings, but most of them only produce a single color. So to create a beautiful light pattern, multiple colors LED strips are used, which are, not only consumes more power but also hard to manage. Today we are using the new generation LED- NeoPixel, which can produce 16.8 million colors. NeoPixels are programmable, and with the right programming, it can create many beautiful lighting patterns. Here a NodeMCU and Blynk app will be used to control the color and brightness of NeoPixel LED strip over the internet. Blynk is a smartphone application, using which we can control any IoT based Application through our smartphone.

Requirements :
● Computer with an internet connection
● Download and install Arduino IDE

Components

NodeMCU ESp8266

USB 2.0 Male to Mini USB Cable

Jumper wires

WS2812 Neopixel

1 nos

breadboard

Breadboard

1 nos

hardware

Hardware

node mcu 8266 wifi

Getting
Started with
Web Switch ESP8266

NODE MCU esp8266

Node mcu is a micro controller which is made under the LUA based firmware and architecture made for IOT application . It also includes expressif systems and hardware firmware ,which is based on the ESP-12 module. It is a very capable microcontroller which can be used easily for IOT applications with the blynk-app . The features are :

  • The operating voltage is 5V
  • The input voltage is between 7-12 v
  • Digital input/output pins are 16
  • Analog i/p pins is 1
  • Flash Memory is 4 MB
  • SRAM is 64 KB
  • CLK Speed is 80 MHz

What is Blynk?

blynk is an app made for smartphones to communicate with arduino and raspberry pi . It has a very neat graphical interface which makes it very easy to control and use . We use this with the NODE MCU esp8266

node mcu esp 8266 pin out

Pin out diagram
ESP8266

WS2812 NeoPixel LED Strip Working

WS2812 LED strips are individually addressable where one can program it in such a way that we can individually program an LED in this strip .We are able to do this with the IC present inside called the 5050 IC. Each of the led consume around 60mA and we can use a 5v power supply .We can program it by using a signal pin from the microcontroller.

Features: 

  • Individually addressable LED
  • 16.8 million color
  • 5v DC
  • 60mA per LED
  • Very flexible LED structure
  • 5050 RGB LED with WS2812 driver

Circuit Diagram

STEP1: CONNECTING NeoPixel TO NodeMCU

Circuit diagram for NeoPixel NodeMCU is given below:

Wire up the NeoPixel Module
With NodeMCU

Connections Explained:-

LED VCC -> NodeMCU Vcc

LED GND -> NodeMCU GND

LED Data -> NodeMCU Digital D1

Blynk Application Setup for controlling NeoPixel

Blynk is an application that runs over Android and IOS devices to control any IoT based application using Smartphones. We previously used Blynk with NodeMCU and Raspberry Pi to control an LED and also build a weather station using the Blynk app. It allows you to create your Graphical user interface for IoT application. Here we will set up the Blynk application to control NeoPixel LED over Wi-Fi using NodeMCU ESP8266.

So first download and install the Blynk Application from Google Play store (IOS users can download from App Store) and sign-up using your Email id and Password.

 

Creating a new Project: 

 

Step 1: Create  a Blynk account 

After successful installation, open the application and click on “New Project”. Then it will pop up a new screen, where we need to set the parameters like Project name, Board and connection type. For this NeoPixel ESP8266 project select the device as NodeMCU and connection type as Wi-Fi and click on “Create”.

Step 4: Go to project settings and copy Auth Token to clipboard -or- which will be sent to your email account.

After the successful creation of the Project, we will get an Authenticate ID on registered mail. Save the Authenticate ID for future reference

The Blynk app automatically sends you a unique authentication code for every new project you create. You need this code to connect your smartphone to the hardware. The authentication code will be sent to the email address you used for registration.

Step 5: adding a widget on widget box select  Labeled Value

Creating the GUI: Open the project in Blynk, click on the “+” sign to add the widgets to control the NeoPixel. In our case, we need an RGB Color Picker which is listed as “zeRGBa” and a slider that will be used for brightness control of the LED strip.

In our case, we need an RGB Color Picker which is listed as “zeRGBa” and a slider that will be used for brightness control of the LED strip.

Setting the Parameter in Widgets: 

After dragging the widgets, they now set their parameters which are used to send the color and brightness values to NodeMCU.

Click on ZeRGBa, to go into ZeRGBa setting and set the Output option to “Merge” and set the pin to “V3” which is shown in the image below. 

Similarly, in Slider settings, set the output pin to “V2.”

Program NodeMCU and Read input the input from BLYNK App after pressing run Button as show. 

PROGRAMMING

The NodeMCU programming can be as easy as in Arduino, the main difference is the distribution of pins in the nodemcu board. Following below operations and enjoy your first NodeMCU & Arduino IDE

Step 1: Install the Arduino IDE 1.6.4 or Greater

Download Arduino IDE from Arduino.cc / superkitz.com You can use your existing IDE if you have already installed it. You can also try downloading the ready-to-go package from the ESP8266-Arduino project if the proxy is giving you problems.

Download Arduino IDE

In order to upload code to the ESP8266 and use the serial console, connect any data-capable micro USB cable to ESP8266 IOT Board and the other side to your computer’s USB port.

 

The new version NodeMCUv1.0 comes with the CP2102 serial chip, you can download (also provided with the kit)  and install the driver from https://www.silabs.com/products/development-tools/…. The NodeMCUv0.9 comes with the CH340 serial chip, you can download and install the driver from: https://github.com/nodemcu/nodemcu-devkit/tree/mas…

 

 

Step 2: Installing NodeMCU package for Arduino IDE

Paste the copied link(givenbelow) and insert it(add. boad Manager URL) in Arduino IDE using the following sequence->File menu -> Preferences-> Paste copied link into the area shown in the black box in the above image. Close and restart the Arduino IDE.

The link should look something like this:

http://arduino.esp8266.com/stable/package_esp8266com_index.json

Paste the copied link and insert it in Arduino IDE using the following sequence->File menu -> Preferences-> Paste copied link into the area shown in the black box in the above image. Close and restart the Arduino IDE.

Tools -> Boards manager and search for ESP8266 and install the libraries/files given under the heading ESP8266 by ESP community.

Restart the Arduino IDE once again.

Scroll down, select the ESP8266 board menu and install “esp8266 by ESP8266 Community”, as shown in the figure below.

If you used the Installer, Windows – from XP up to 10 – 

  1. Delete the Documents -> Arduino -> Libraries to remove all your libraries.
  2. Delete the User -> AppData -> Local -> Arduino15 folder to remove all the preferences.
  3. Uninstall Arduino IDE.
  4. Install a fresh one.

If you used the -Mac OX  from  –

First of all, make sure to log into your Mac with an administrator account, or you will be asked for a password when you try to delete something.

Open the Applications folder in the Finder (if it doesn’t appear in the sidebar, go to the Menu Bar, open the “Go” menu, and select Applications in the list), search for Arduino 1.6.4 application by typing its name in the search field, and then drag it to the Trash (in the dock) to begin the uninstall process. Alternatively you can also click on the Arduino 1.6.4 icon/folder and move it to the Trash by pressing Cmd + Del or choosing the File and Move to Trash commands.

Remove all components related to Arduino 1.6.4 in Finder
Though Arduino 1.6.4 has been deleted to the Trash, its lingering files, logs, caches and other miscellaneous contents may stay on the hard disk. For complete removal of Arduino 1.6.4, you can manually detect and clean out all components associated with this application. You can search for the relevant names using Spotlight. Those preference files of Arduino 1.6.4 can be found in the Preferences folder within your user’s library folder (~/Library/Preferences) or the system-wide Library located at the root of the system volume (/Library/Preferences/), while the support files are located in “~/Library/Application Support/” or “/Library/Application Support/”.

Open the Finder, go to the Menu Bar, open the “Go” menu, select the entry:|Go to Folder… and then enter the path of the Application Support folder:~/Library

Search for any files or folders with the program’s name or developer’s name in the ~/Library/Preferences/, ~/Library/Application Support/ and ~/Library/Caches/ folders. Right click on those items and click Move to Trash to delete them.

 

Go to Tools – Boards (scroll down the list of boards) – Select NodeMCU 1.0 ( ESP-12EModule).

Select the Port number at which you have connected nodeMCU. The rest of the settings can be left to default values.

Install Library for Arduino IDE

 Install Blynk as ZIP file in Arduino IDE

Blynk library is available as a downloadable ZIP. Starting with Arduino IDE version 1.0.5, you can install 3rd party libraries in the IDE.

Download Blynk Library by clicking the button: Download Blynk Library

Do not unzip the downloaded library, leave it as is.

  1. In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library. At the top of the drop down list, select the option to “Add .ZIP Library‘. 
  2. Then select the library zip file you have downloaded. 
  3. Return to the Sketch > Include Library menu. menu. You should now see the library at the bottom of the drop-down menu. It is ready to be used in your sketch. The zip file will have been expanded in the libraries folder in your Arduino sketches directory.

 Install FastLED 3.3 as a ZIP file in Arduino IDE

Download FastLED 3.3 Library by clicking the button: Download FastLED 3.3

Similarly, install Fast LED.


Press CNTRL + A and press DELETE on keyboard for clearing the Arduino IDE page

Copy paste the code and click upload

Arduino Code

Download the Arduino source code.

Before sending the values, we must configure the Wi-Fi settings

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>  
#define FASTLED_ESP8266_RAW_PIN_ORDER
#include "FastLED.h"
#define NUM_LEDS1 60
#define LED_TYPE    WS2812
#define COLOR_ORDER GRB
CRGB leds1[NUM_LEDS1];
char auth[] = "wQTLlQHZbH42GQxDZU8NFqoLEhi-YXH8"; // Replacing with your auth code
char ssid[] = "YourWifiName"; // Replace with wifi name.
char pass[] = "YourWifiPassword"; // Replace with wifi password.
#define PIN1 D1
int data=255;
int r,g,b;
void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  FastLED.addLeds(leds1, NUM_LEDS1).setCorrection( TypicalLEDStrip );
}

BLYNK_WRITE(V3)
{
  r = param[0].asInt();
  g = param[1].asInt();
  b = param[2].asInt();

  static1(r, g, b,data);
}

void loop()
{
  Blynk.run();
}
BLYNK_WRITE(V2)
{
data = param.asInt(); 
static1(r, g, b,data);
}
void static1(int r, int g, int b,int brightness)
{
  FastLED.setBrightness(brightness);
  for (int i = 0; i &lt; NUM_LEDS1; i++ )
  {
    leds1[i] = CRGB(r, g, b);
  }
  FastLED.show();
} 

Running the System

Press the Run button to start the Blynk App. You can see that your gauges will start to display the sensor readings

The values sent from blynk cloud corresponding to the color selected from app. When the value is received  by the nodemcu it changes the Neopixel color corresponding to changes. 

Leave a Reply