Triangular wall shelves under a sloped ceiling, each shelf lit by a string of warm fairy lights.

# Christmas lights hack

Table of Contents

A project the bring a little more mood lighting to my room. Originally I had one Ikea light which was just a little to bright. So I decided to by cheap Christmas lights, but these required batteries and had to be switched off individually, too much effort. So I hacked them be cutting of 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

Triangular wall shelves lit only by a single bright lamp on the bottom shelf
Before: one Ikea lamp, a little too bright

The same shelves lit evenly by strings of warm fairy lights on each shelf
After: fairy lights on every shelf

Shopping list

Itemqtyprice
Wemos D1 mini1 x1.50 €
2N2222 transistor3 x0.10 €
1k resistor3 x0.10 €
30x15mm perfboard1 x0.20 €
DC-DC Buck converter1 x0.30 €
Wire
Christmas lights3 x~1.80 €

Tools

  • Soldering essentials
  • 3D printer

Build log

Every good project of course starts of with a good plan. For this a draw a circuit, which I then tried on a breadboard which seemed to work fine. Initially without resistors, but this caused the ESP the heat up.

The circuit design works as following. There are three LED’s placed before transistors, these transistors control the flow and allow us the digitally switch the LED’s. The transistors are connected to GPIO 5-7 with a resistor to limit the current. The LED’s are powered from a DC-DC buck convert to proved them with 4.5 volts equivalent to 3xAA. The buck converter is connected to the 5v and ground pins.

Hand-drawn schematic on grid paper: three LEDs switched by transistors with 1k base resistors on GPIO 5, 6 and 7, powered by a buck converter from 5V
The circuit plan

Construction

Solder side of the perfboard with resistors and yellow, red and black jumper wires, next to a Wemos D1 mini
The solder side, a bit of a mess

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

Component side of the perfboard with female headers and the buck converter soldered flat, next to a Wemos D1 mini
Headers and the buck converter

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

A string of fairy lights with its battery pack holding three AA batteries
The cheap battery-powered Christmas lights

Then the lights, these are cheap store bought Christmes lights. All we have to do is cut of 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.

A white 3D-printed box and a red lid with a cut-out logo, next to the assembled controller
The 3D-printed enclosure

Then it becomes 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, it looks nice as well.

Home Assistant

Now the construction is finished we can add the code. Some we will use this as in integration with home assistant we can use ESPHOME which allows use to define its functions with just one YAML config.

christmas_lights.yaml
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 logging
logger:
# Enable Home Assistant API
api:
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 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.

My avatar

Thanks for reading my blog post! Feel free to check out my other posts or contact me via the social links in the footer.


More Posts

Comments