NodeMCU + Pixel LEDs

Getting started with the NodeMCU and WS2801 Pixel Leds.

Kurt Schoenhoff


 Today we will be working with the NodeMCU and some WS2801 Pixel LEDs. The marriage of the two should be ideal for the main project. And they are both great to work with.


 The NodeMCU is a board that is based upon the ESP2866 (v12) MicroController this is a MCU has a few features that really make it stand out for this project

1. Easily programmable, either in the Arduino IDE (c) or using Lua.

2.Built In Wifi, connect to a network, use to host a WiFi network as well as mesh network modes, not to mention hosting a webpage!

3. Cheap!! awesome price for the functionality.

4. Built in voltage regulation.

5. Built in USB.

6. Over The Air programmable, program without a usb!

Pixel Leds

We will be using the WS2801 Pixel led's, there are many different types of Pixel LEDs however the basic control of them is split into 2 main categories. 1 wire(data) and 2 wire (clock and data). Both types function is a similar way and this allows you to set the colour of each individual LED within a string, hence the name "pixel LED". 

Odoo text and image block

Odoo image and text block

Meet the Controller - NodeMCU

This ESP8266 based board is able to be used as a Wifi access point or can connect to an existing WiFi network as well as being able to manage its own mesh network depending on the software it is programmed with.

It operates at 3.3v and has a built in voltage converter that allows it to be powered straight from your USB or some batteries if you wish.

We will be using the Arduino IDE to program the MCU, you will need to install the ESP8266 drivers and library to use it within the arduino IDE. See the instructions in the link provided for info on how to get setup in your IDE.

Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. We have packages available for Windows, Mac OS, and Linux (32 and 64 bit).

  • Install Arduino 1.6.8 from the Arduino website.
  • Start Arduino and open Preferences window.
  • Enter into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas.
  • Open Boards Manager from Tools > Board menu and install esp8266 platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation).

*note: this MCU is also able to be programmed using LUA if you are interested.

Pixel Leds

We will be using the WS2801 chip based pixel LEDs,These are a digitally addressable chip using a constant current driver for each LED. In each package there is 1 WS2801 chip controlling 3 LEDs (Red, Green, Blue). Each LED is controlled using 0-255 / 8 bits allowing you control over the intensity of each coloured LED giving you 16 Million colours / 24 bit colour for EACH package.

The data is shifted from the first unit in the chain where the chip will take its colour from the data and relay the rest of the information to the next chip, which does the same. This method allows you to create a long chain of values for you LEDs that will be picked off in turn by each unit. The first unit in the chain takes the first set of values and the chain of data get progressively shorter as it goes past each unit in sequence.

The units we are using are designed to run from 5v for power as well as signal, however as 3.3v is above the threshold for the high bit state they will function as desired when controlled directly from the NodeMCU without the requirement for level shifting. As we are only using short lengths (10 LEDS per string) the whole lot can be powered from the USB on your PC which greatly simplifies the wiring and setup. 

To make controlling these units even simpler we will be using the library which now supports ESP8266 based MCU's. simple find your way to the github page and download or clone the repository, then copy the whole folder into your arduino IDE library folder. If you downloaded a zip from github you will need to remove the "-master" from the folder name for the Arduino IDE will not load the library. Restart your Arduino IDE if you had it open and you should be able to checkout some of the examples.

When using the nodeMCU with FastLED it is helpfull to define


before the line you have

"#include <FastLED.h>"

That way you can use the pin names as they are printed on the nodeMCU otherwise you will have to use the chart at the top of this page to translate the output pin names. 

Odoo text and image block 

Intro Code

The example provided is a simple way to test you have connected your Pixel LED's correctly and that they are all working.

You copy and past this into your Arduino IDE and save as a new project.

Make sure you have the right processor (nodeMCU 1.0) and the correct Com port selected in the IDE.


// This program was taken from the FirstLight.ino supplies with the FastLED library
// It has been modified for use with a NodeMCU for use in a tutorial by
// Hosted at
// Special thanks to the people behind and all the contributors :)

#define FASTLED_ESP8266_NODEMCU_PIN_ORDER // map output pins to what they are called on the NodeMCU
#include "FastLED.h"

// Move a white dot along the strip of leds. This program simply shows how to configure the leds,
// and then how to turn a single pixel white and then off, moving down the line of pixels.

// How many leds are in the strip?
#define NUM_LEDS 10

// Data pin that led data will be written out over
#define DATA_PIN 3

// Clock pin only needed for SPI based chipsets when not using hardware SPI
#define CLOCK_PIN 2

// This is an array of leds. One item for each led in your strip.

// This function sets up the ledsand tells the controller about them
void setup() {
    // sanity check delay - allows reprogramming if accidently blowing power w/leds
FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);

// This function runs over and over, and is where you do the magic to light
// your leds.
void loop() {
// Move a single white led
for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1) {
// Turn our current led on to white, then show the leds
leds[whiteLed] = CRGB::White;
// Show the leds (only one of which is set to white, from above);
// Wait a little bit
// Turn our current led back to black for the next loop around
leds[whiteLed] = CRGB::Black;