Last week a new order from China arrived. I’ve ordered a RGB led strip, with some wifi controller that should be based on the ESP8266 chip and is said to be hackable. I gave it a try and wrote my own software for it.
I’ve ordered three items:
The most interesting part is the H801.
Above is the outside of the H801 controller. It has connections for R/G/B/VCC(out) on the left side, and W2(warm white)/W1(white),GND,VCC(in) on the right side. There are two onboard leds, for power and wifi. Upon powering the controller, a wifi access point is created by the controller. The seller sent me an email with an Android application, which can be used to connect to the access point of the controller and control the leds.
I did not quite liked this setup, as I do not own an Android device, neither do I want to connect to the wifi network of this controller everytime I want to change the color. In the same topic on the Domoticz forum that made me order this little device, I found a link to a blogpost on Hackaday. This blogpost claims that there are pins available on this board to reprogram the device. Interesting..
When taking of the casing, there is a small circuit board which includes the ESP8266 chip. It is the little square chip in the middle of the next photo.
On the chip were also 4 connection points for TX, RX, GND and 3V3. I’ve soldered some pins onto the board, so I could hook it up to my FTDI USB programmer. If you power the device with 12V on the VCC(in) and GND like I did, it is not necessary to use those pins on the board. I also soldered two pins onto the J3 (jumper 3) connection, which should be shorted before powering the device to get it into programming mode.
When I connected this to my PC, I was able to program the device using the Arduino IDE. You have to install the ESP8266 in the IDE using the Board Manager to be able to select the Generic ESP8266 board in the Arduino IDE. And you probably need the Arduino ESP8266 libraries.
At the bottom of this post you can find some example code I wrote to test this device. The code connects the device to the specified wifi network, and start a webserver on the IP it gets from the DHCP server (this IP is printed to the serial upon boot). Using a simple http call to the device on http://192.168.0.xx/rgb/ff0000 it is possible to send RGB values in HEX and let the color of the leds change to this color. The code also uses some logic to include a nice fade effect between changing colors. It is far from perfect right now,
as it does not include white/warmwhite (it does now, see update below) and has some bugs which make the colors flash very fast every now and then during a fade.
I’ve included a video below to show the result. In this video I’ve used a script on my PC to make a call to the H801’s webserver every 2 seconds, and change it to a different color. When i’m ready to mount the led strip into my living room, I will update the code and implement it into my home automation system.
Update 08/02/2016: Thanks to Jeff, I found out there was a bug in the code. It seems that the analogWrite function on the ESP8266 uses a range of 0-1023, where the normal Arduino uses 0-255. Some of the variables in the code used “byte” as type, so they could not go further than 255. Right now those are changed to integers, so the full 0-1023 range can be used. This results in much brighter leds! As I was debugging and updating the code, I’ve took the time to finish it by adding the W1 and W2 values as well. So any LED strip with RGBW and RGBWW can also be used now. It is used the same way as described above, only with different URL’s: http://192.168.0.xx/w1/ff and http://192.168.0.xx/w2/ff
Update 12/02/2016: I’ve created a new blog post, were I wrote how I’ve created my own ESP8266 based Wifi LED Dimmer. It’s very suitable for LED Strips that do not require the RGB functionality. Please take look at ‘ESP8266 Wifi LED Dimmer‘.
eryk October 28, 2015