
# Christmas lights hack
Table of Contents
A project to bring a little more mood lighting to my room. Originally I had one Ikea light which was just a little too bright. So I decided to buy cheap Christmas lights, but these required batteries and had to be switched off individually, too much effort. So I hacked them by cutting off the batteries and connecting them to an ESP controller such that I could control them via Home Assistant with just one button press.
Before and after


Shopping list
| Item | qty | price |
|---|---|---|
| Wemos D1 mini | 1 x | 1.50 € |
| 2N2222 transistor | 3 x | 0.10 € |
| 1k resistor | 3 x | 0.10 € |
| 30x15mm perfboard | 1 x | 0.20 € |
| DC-DC Buck converter | 1 x | 0.30 € |
| Wire | ||
| Christmas lights | 3 x | ~1.80 € |
Tools
- Soldering essentials
- 3D printer
Build log
Every good project of course starts off with a good plan. For this I drew a circuit, which I then tried on a breadboard which seemed to work fine. Initially without resistors, but this caused the ESP to heat up.
The circuit design works as follows. There are three LEDs placed before transistors. These transistors control the flow and allow us to digitally switch the LEDs. The transistors are connected to GPIO 5-7 with a resistor to limit the current. The LEDs are powered from a DC-DC buck converter to provide them with 4.5 volts, equivalent to 3xAA. The buck converter is connected to the 5V and ground pins.

Construction

It became a bit of a mess because I mirrored the pins incorrectly at first. After that I also had to add resistors to the already finished board. But everything still fitted within the footprint and I called it good enough.

On the other side are all the headers and the buck converter. The buck converter is soldered to the board to make it more low profile and fit under the ESP. On the converter the traces at adjust are connected, allowing me to turn the potentiometer on the other side to set the voltage. This was set to 4.5V. The top headers allow us to plug in the Christmas lights.

Then the lights. These are cheap store-bought Christmas lights. All we have to do is cut off the battery pack and connect a male header to them. I used these connectors because these were the smallest connectors I had around. I also created some wire extensions to connect the light to the controller. These are just simple wires with headers connected to them.

Then it is time to create an enclosure. The electronics are just housed in a simple box with two holes. One for the USB and the other for the light. The logo is cut out to allow more heat to escape, and it looks nice as well.
Home Assistant
Now that the construction is finished we can add the code. Since we will use this as an integration with Home Assistant, we can use ESPHome, which allows us to define its functions with just one YAML config.
esphome: name: christmas_lights platform: ESP8266 board: d1_mini_lite
wifi: ssid: "WIFINAME" password: "PASSWORD"
# Enable fallback hotspot (captive portal) in case wifi connection fails ap: ssid: "Christmass Ligths" password: "FALLBACKPASSWORD"
captive_portal:
# Enable logginglogger:
# Enable Home Assistant APIapi:
ota:
output: - platform: esp8266_pwm pin: 12 frequency: 1000 Hz id: pwm_output0 - platform: esp8266_pwm pin: 14 frequency: 1000 Hz id: pwm_output1 - platform: esp8266_pwm pin: 13 frequency: 1000 Hz id: pwm_output2
light: - platform: monochromatic output: pwm_output0 name: "shelfTop" - platform: monochromatic output: pwm_output1 name: "shelfMiddle" - platform: monochromatic output: pwm_output2 name: "shelfBottom"With that flashed we can now use our new smart lights. I use the lights with an automation which turns them on when the sun is down. But there can be many examples of interesting use cases.