loading

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, http://www.adafruit.com/product/2471
  2. 3.7v LiPo battery such as https://www.adafruit.com/products/1317
  3. FTDI programmer such as http://www.adafruit.com/product/284 or USB-to-serial cable
  4. small switch such as https://www.adafruit.com/products/805
  5. Neopixels (aka WS2812 LEDs) such as https://www.adafruit.com/products/1463
  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).

Assembly:

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: https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/using-arduino-ide 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:

https://www.arduino.cc/en/Main/Software and install it.

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

http://arduino.esp8266.com/versions/2.0.0/package_...

Use the Board Manager to install that ESP8266 (Following Adafruit's Arduino ESP8266 setup instructions here: https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/using-arduino-ide)

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.

[NOTE: DON'T USE PIN 16 FOR NEOPIXELS].

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, http://www.esp8266.com/, and http://www.whatimade.today/esp8266-easiest-way-to-program-so-far/ for all the original source material.

<p>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?</p>
<p>Grat project! What about battery life? How long it can last on batteries?</p>
<p>Good job Sir its very Cool project ,very interesting!! i'll make it!!!</p>
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?
<p>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.</p>
Glad you're doing that. Thanks for pitching in! <br><br>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. <br><br>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.
<p>...and started<br>https://github.com/TheExpertNoob/ESP8266-Wifi-NeoPixel/blob/master/README.md</p>
<p>Thanks for the tutorial. Very well written, great to have everything in one place.</p>
<p>Thanks, glad this helped!</p>
<p>I thought nexopixels require 5V power and 5V signal</p>
Thanks for checking: they can actually be powered by lower voltages. Too low and you might lose color fidelity. See here for more info: https://learn.adafruit.com/adafruit-neopixel-uberguide/power<br><br>
<p></p><p>Why I can't finish, gpio output is Unlike the arduino</p>
<p>Hi finalvalue,</p><p>I'm sorry that you're having trouble. Can you be more specific about exactly what problem you're having?</p><p>Thanks!</p>
<p>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</p>
<p>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.</p>

About This Instructable

47,256views

175favorites

License:

More by Rocktakon:Internet of Toots (IoT): A Social Whoopee Cushion Relieve Itching From Poison Oak ESP8266 controlling WS2812 Neopixel LEDs using Arduino IDE - A Tutorial 
Add instructable to: