Cheerlights cube with Adafruit’s HUZZAH ESP8266 Breakout (without thingspeak API)

IMG_20160902_211736

Cheerlights is an awesome example of an IOT (Internet Of Things) collaborative project. It allows all users lights across the world to synchronize to one color. For that, it uses a Thingspeak channel and API. More information about the project you can visit its page.

Requirements

1x Adafruit HUZZAH ESP8266 Breakout

1x WS2812 Serial 5050 Full-color LED Extension Module For Arduino

Note: You can use any NeoPixel compatible led strip, led ring, RGB LED, etc… I’ve build and enclosure for this one i’m using

Schematics

Here’s a Fritzing schematic of the project and its connections.

CheerLights_bb

Note: The TTL cable is only used when uploading code. I’m drawing power from a USB port. I’ve just cut a USB cable and used the USB -> Computer adapter to connect to a USB port and get power from there.

Enclosure

To create this funny project, I reused a small white acrylic cube I had around here from another Arduino project. I had two, one was used in my project –

Arduino LED Ambient Mood Light with Light/Luminosity/LUX Sensor – and the other one I’m going to use it here.

I’ve created a base for the cube, where the HUZZAH and the LED ring will be put and connect to a USB port.

Here are some pictures of the base being printed. You can get it from Thingiverse.

IMG_20160822_085213 IMG_20160822_085218

IMG_20160902_210117 IMG_20160902_210122 IMG_20160902_211331 IMG_20160902_211629 IMG_20160902_211707 IMG_20160902_211718 IMG_20160902_211736 IMG_20160902_211756

Code

Cheearlights uses Thingspeak API to know when a color has changed and change the RGB LED accordingly. When you install the thingspeak library there’s an example for cheerlights. I’ve tried to use that example, but my HUZZAH was always crashing with the “wdt reset”. I was unable to solve this error, no matter what I did – pull ups, pull downs, resistors – nothing worked.. After some testing, I realized that if I removed some code, the HUZZAH worked like a charm. I decided not to use the Thingspeak API and make my own functions.

According to Cheerlights API, you can get the latest color in 3 different formats: XML, JSON and plain text. Plain text just returns the name of the color and nothing else. By using string functions I can get the color.

But, I decided to add a special feature – instead of changing directly from one color to another, I added a transition like effect.  We have the old color, the new color and in 10 steps (You can change that if you like), change from one color to the other.  It works better (the effect is better perceived) if the old color and the new color RGB values are far apart.

Support for Adafruit’s Huzzah board

First, We need to add support for the Adafruit Huzzah board. You can see here how to add support in the Arduino IDE

Note: Your Arduino IDE must have been downloaded from arduino.cc.

Install (if you like) Thingspeak libraries. It has an example for Cheerlights. Go to this Github page to read how to install the library.

The Code

Here’s a tweet with the result:

Hope you all like it !

References

https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout

https://learn.adafruit.com/cheerlights

http://cheerlights.com/

Leave a Reply

Your email address will not be published. Required fields are marked *