Some time ago I started working on the idea of making our house smarter. One of the first things I created was a sensor that measures temperature, humidity and atmospheric pressure. For monitoring and managing these devices, I am using the wonderful, open source HomeAssistant platform.
One thing that I didn't yet get around to, was actually having something to control like a wall switch or a light. That was until about 3 weeks ago when I read Xose Pérez' excellent article on how to upload your own firmware to an inexpensive WiFi RGB light bulb.
This got me very intrigued and so I started on a journey creating an alternative firmware called AiLight...
The Ai-Thinker LED Bulb is being made by a Chinese company called Ai-Thinker and has an ESP8266 at its core. This is a micro controller well known to me and the first release of a library was born quickly. Although the library was fine as it was, I felt compelled to build a complete firmware. A firmware that was easy to use and modify by other developers but more important - easy to use by anybody in our house. And of course, connecting to HomeAssistant without any pain.
Many Smart WiFi LED bulbs come with an app that allows you to manage the light over the Internet. Making an alternative firmware would also mean that such app can not work any longer. Having only minor experience in developing apps, I decided to develop a responsive HTML UI instead. With comparable features as the manufacturer's app. The ESP8266 is well suited for that as it can act as a decent HTTP server!
To explain why this became a challenge, we need to look at the ESP8266 HTTP server part. For the UI to show in real-time the brightness level, for example, fast data exchange is needed.
This is where the WebSocket protocol is a perfect partner. The WebSocket protocol enables interaction between a browser and a web server with lower overheads, facilitating real-time data transfer from and to the server.
After two weeks of hacking and modding, a first Alpha release is ready! So what can this AiLight firmware then do, you might ask? The AiLight firmware allows you via WiFi to:
- switch the light on or off
- set the level of the 4 colour channels (Red, Green, Blue and White)
- set the brightness level
- set the light at a particular colour temperature
- let the light flash (with a defined colour and brightness)
- after powering on the light again, the last known settings are remembered (colour, brightness, etc.)
The UI interface also gives you the ability to configure the light remotely. You can easily change your WiFi settings or the configuration of your MQTT broker.
The AiLight firmware is completely open source and can be found on GitHub. If you like to try it yourself please have a look at the Github page. The firmware is still at an early stage so some issues can be expected.
Enjoy! Please feel free to leave comments or feedback here. Happy to hear what you think!