ESP8266 Controlling WS2812 Neopixel LEDs Using Arduino IDE - a Tutorial




Introduction: ESP8266 Controlling WS2812 Neopixel LEDs Using Arduino IDE - a Tutorial

Hi everybody,

If you're like me, you've been looking around the internet for a good tutorial on using the ESP8266 with neopixel LEDs (AKA the WS2812 or WS2812b), programmed via the Arduino IDE. I haven't found it all in one place, in English, but it turns out it's pretty easy now - much better than a few months ago. First, props to sabas1080 for his instructable, which does a nice job of this in Spanish. I'm documenting it here in English in case this helps others.

This is a basic breadboard demonstration. It's not meant to be a "final product" but consolidates instructions for this basic setup. If you haven't used the ESP8266 yet, it's an awesome little wifi board that you can get for a few bucks. Even the fancy version is only $10.

Note that this DOES NOT require a separate Arduino board, it's running the neopixels directly from the ESP8266 and just programming it with the Arduino IDE. And thanks to the hard work of many people it's now very easy!

Come see...

Step 1: Parts and Assembly

Parts you'll need:

  1. an ESP8266, I used Adafruit'sHuzzah breakout,
  2. 3.7v LiPo battery such as
  3. FTDI programmer such as or USB-to-serial cable
  4. small switch such as
  5. Neopixels (aka WS2812 LEDs) such as
  6. Capacitor to protect your neopixels - I have a 1000 uF here.
  7. ~470 ohm resistor
  8. Breadboard
  9. Wire

Note: using the Huzzah breakout board makes things easier because it has buttons built in for reset and bootloader mode. if you're using a bare ESP8266 board, you'll want a couple additional buttons to use for reset and putting the ESP8266 in the bootloader mode (to upload your code to it).


Assemble as shown in the diagram above. The capacitor and resistor help protect your neopixels. I'm using a neopixel ring because that's what I happen to be working on, but you can test with a strip or a single pixel or whatever you have. If you are using the Adafruit Huzzah breakout, solder it as shown on their nice page here: using your breadboard.

You'll need the FTDI cable or USB for programming. After the programming is finished, you can remove it. Speaking of which, let's program this thing.

Step 2: Code and Programming

First, you need to make sure you have a version of the Arduino IDE that is at least 1.6.4. Get it here: and install it.

Then go to File --> Preferences and at the bottom under "Additional Board Managers", enter:

Use the Board Manager to install that ESP8266 (Following Adafruit's Arduino ESP8266 setup instructions here:

Tools --> Board select generic ESP8266 (Or Adafruit Huzzah ESP8266 if you're using that) and use these settings:

  • CPU Frequency: 80 MHz
  • Upload speed: 115200
  • When you plug in your FTDI, select the correct COM port for it.

Make sure you also install the neopixel library for Arduino if you haven't already. Get it using the library manager

  1. In the Arduino Go to Sketch --> Include Library --> Manage Libraries (it's at the top of the list)
  2. Type "neopixel" in the search box
  3. select the Adafruit neopixel library and install

Now get your sketch ready. You can use the generic StrandTest sketch in the examples menu under the Adafruit NeoPixel folder. Set the number of pixels you're using and set the data pin - I'm using pin 14.


Put the board in bootloader mode.

  • If you're using the Huzzah breakout, this means holding down the GPIO0 button, pressing and releasing the resent button, then releasing the GIO0 button.
  • If you're using a bare ESP8266 instead, then temporarily connect GPIO0 to ground, toggle power to the reset pin,then disconnect GPIO0 from ground.
  • If you've done one of the above correctly, the on-board LED should be dimly on.

Now upload the sketch using the Arduino IDE. This will take a while and you will probably see the on-board LED flicker during transfer.

Now that you've uploaded the sketch, let's see if it works. Flip the switch on your battery and you should see your neopixels light up.

Congratulations, you're halfway to making the next big IoT device! Have fun making things light up from afar with your ESP8266.

Hope this saves you time scouring multiple sites to put it all together. Thanks to Adafruit,, and for all the original source material.

2 People Made This Project!


  • Tiny Home Contest

    Tiny Home Contest
  • Metalworking Contest

    Metalworking Contest
  • Creative Misuse Contest

    Creative Misuse Contest

15 Discussions

When I connected the capacitor, the led strip stopped working.Was it burned?

I have a 5v 9A ledstrip, which transistor and capacitor do i need to use?

I'm trying to set this up with the first ESP-01 Module. Please could you help with how the pins should be hooked up?


Grat project! What about battery life? How long it can last on batteries?

Good job Sir its very Cool project ,very interesting!! i'll make it!!!

Cool project. Thanks for putting forth the effort to help people learn. One question though, since your using the ESP8266, it seems as though the article would include info on how to actually control the pixels via wifi. Am I missing something?

3 replies

Working on it. But I seem to be running out of space. Trying to consolidate code to get it to fit. Look into the ESP8266 example sketches(ive started with captive portal for a direct connection when no wifi router is around). if/then/else; ive programmed in based on the indexOf url (ex /rainbow/ or /red/ or /redc/ for red chasing ect) and buttons to pass it to the url. Code is sloppy right now, but hopefully I'll have something soon.

Glad you're doing that. Thanks for pitching in!

It wasn't my intent with this one, since there many different ways you can do this depending on what you want and I had other plans for the control and just needed to figure out the ESP8266 interface w/ the neopixels.

I'm glad others are contributing, and I'd be glad to update this instructable to point to another that demonstrates how to control via wifi.

...and started

I thought nexopixels require 5V power and 5V signal

1 reply

Thanks for checking: they can actually be powered by lower voltages. Too low and you might lose color fidelity. See here for more info:

Hi finalvalue,

I'm sorry that you're having trouble. Can you be more specific about exactly what problem you're having?


I tested, control individual leds by Blink can be normal operation!But, with 12 for the lamp ring cannot normal control, lamp ring no response

Double-check that you are using the same pin and matching pin assignment in the software. Also double check that you have enough power for the LEDs. you might want to add a large-ish capacitor (like 1000 uF) across the + and - power rails, as both the ESP8266 and the LEDs can have large and spikey current draw.