In this post I will walk you through the moving parts required to build an ambient light system. The light will be controlled by any of the following:
- Siri (via HomeKit) – voice activation and configuration (power state, brightness, colour)
- HomeKit – software activation and configuration (power state, brightness, colour)
- Touch sensor – hardware activation and configuration (power state, brightness)
This is not a step-by-step guide but rather a description of the components involved and how the whole thing is put together.
The image bellow describes the overall architecture depicting the MQTT server as the central integration point.
The communication pattern is designed to adhere to the MQTT Smart Home Architecture, described here.
- Arduino Uno – buy on ebay
- ESP8266 – ESP01 – buy on ebay
- LM1117T 3.3v voltage regulator – buy on ebay
- Beefy 5v power supply – buy on ebay – I used the 10 amps version, but you might get away with less
- WS2812B LED strip – buy on ebay
- Capacitive touch switch button – buy on ebay
- 2 x 1000uF capacitor – buy on ebay
- Raspberry Pi – Optional – buy on ebay
The Arduino is the controlling unit and uses the ESP8266 chip to achieve wireless connectivity. There will be only one power supply (5v 10a) powering the Arduino, ESP8266 and the LED strip. Therefore, a 3.3v voltage regulator is necessary for the ESP8266 chip, a capacitor should be used together with the regulator to smooth out any ripples.
The WS2812B strip supports addressing every LED individually, however, this functionality was not used and the strip is controlled as a whole. The strip is by far the most power hungry of all components and special care should be taken to pair it with a suitable power supply. Keep in mind that each LED is actually composed out of 3 coloured LEDs (red, green, blue) that draw up to 60 milliamps at maximum brightness white.
The capacitive touch switch is used to manually turn the strip on or off, or to adjust the brightness level. A short sensor touch will cause the power to be toggled on/off while keeping the sensor touched will cause the brightness to gradually increase.
The Raspberry Pi does not play an active role in the hardware setup. It is used to host various software programs and can easily be replaced by a desktop, laptop or NAS.
Controlling the ambient light system is performed by a suite of software:
- LEDStripController – runs on the Arduino and is responsible for communicating with the LED strips, publishing and responding to MQTT messages, and responding to the touch sensor inputs.
- Espduino – firmware and software for the ESP01 chip to avoid working with AT commands.
- Mosquitto – MQTT server, running on the Raspberry Pi.
- Homekit2mqtt – HomeKit to MQTT bridge, running on the Raspberry Pi.
If you are going for a similar setup, keep in mind that Espduino is discontinued! I recommend using an ESP12 instead of the Arduino+Esp01 combination.
In case of network loss ESP01 automatically tries to reconnect to the wifi, however there are times when the chip stops responding entirely. To mitigate this issue a “watchdog” was set in place to hard reboot the chip (power cycle) when it stops responding.
In the general usage pattern a burst of messages are sent to the controlling pair (ESP01+Arduino) and processing those messages is prioritised over updating the hardware (actually turning the LED strip on and configuring each LED according to the chosen colour and brightness). This debounce is controlled by the HARDWARE_UPDATE_DEBOUNCE parameter.
Touching the touch sensor for a short period of time triggers a power toggle, while keeping the sensor touched causes it to cycle the brightness in steps. It takes 10 steps to go from the lowest to the highest brightness level.
Here are a few pictures from the assembly process