Note: This post was previously titled 'Philips Hue Fiber Optic Light'. It was changed based on some feedback on HackeNews. I forgot to mention the words DIY, Hack or Clone in the title.
After making a Philips Hue clone, I realized that it would look really nice with a Fiber Optic light. I found a cheap $3 light on AliExpress. It arrived yesterday and seems to have rather decent build quality, for $3 that is. Here's how mine looks.
Next thing I did was of course a teardown...
- Looks like there's three LEDs in there, one each of R-G-B.
- Here's how the optic fibers look like.
- Opening up the base revels a rather simple circuit, board, button and battery, thats it.
- Looking under the board, there's not much.
- Hmm, I think I can make this better.
- Oh look, a NodeMCU board fits in perfectly in the battery compartment!
- Let's remove the LEDs so I can put some NeoPixels on there.
- I just need this board as a base for the NeoPixels
- Here's my shoddy soldering job, I hope it works.
- Some electrical tape to prevent shorting
- Everything seems to work! Let's put it all back in.
- Here's the final result
- Let's see it in action!
Turn On/Off and set any color with Siri.
Set brightness with Siri.
NeoPixel animations possible too, but not the best fit for hte HomeKit use case.
Powered with a phone charger using a micro USB cable.
OTA programmabe, in case something breaks, the micro USB cable works too.
Fibert optic light: There are cheaper ones ~$1-2, but I needed some space to put in the ESP8266 board and NeoPixels.
NodeMCU V1.0 board: Even the Wemos D1 Mini will do.
Micro USB Cable: These braided ones are very flexible.
Phone Charger: You can use practically any phone charger you might find at home. I got some dirt cheap ones. All I wanted was something small with a USB port on it.
The ESP8266/Arduino side of things is rather easy here. Setting up the HomeKit part using HAP-NodeJS needs some work. I have a detailed post on how to do that here. If you're not interested in in HomeKit, you can also host a html page on the ESP8266 and control the NeoPixel colors using websockets.
Whenever this accessory recieves either On/Off or Hue, Saturation and Brightness values from an iOS device, it publishes them on MQTT topics
FountainLightBrightness. I originally wanted to name this 'Fountain' but Siri kept confusing Fountain with Phone, so I had to go with something discreet.
On bootup the ESP8266 connects to Wifi and subscribes to MQTT topics
FountainLightBrightness. Whenever it receives a value on these topics, it sets the NeoPixel strip with those values.
HomeKit treats lights as single color lamps. However, NeoPixels can do more. It would be nice to sneak in some color fading. It's technically very easy to do but Siri (HomeKit API) doesn't really let you specify anything other than Hue, Brightness and Saturation. When you say Turn on the light, HomeKit just sends an 'on' command. We could interpret this command as a trigger to start a fading animation. However, since we're constantly listening to MQTT messages over WiFi, it would be better to use the DMA controlled esp8266ws2812i2s library for this. For some reason this didnt work today for me, will give it a try some other day. Note that the NeoPixels data pin needs to be connected to GPIO03 or RX pin of the ESP8266 for this library.