So I've got 2 sets of outside Christmas lights, one has a timer on the plug, the other one doesn't, they both have a bunch of effects, but they're not quite the same but they are both 31V with pairs of lights going opposite ways on each string.. I hunted high and low for a controller that can connect a few standard 31V Christmas light plug strings and control more than one at a time, but come up empty.
So I got myself on Amazon and got:
- ESP32-C3 - a tiny computer with WIFI, Bluetooth, USB and a bunch of GPIO pins you can use to control other things
- Buck converter, to take the 31V down to 5V that the ESP32-C3 needs
- A DRV8871 chip, which is motor driver - it takes the 31V input plus 2 PWM inputs, and outputs between -31V to 31V across the wires, depending on the PWM inputs. This attaches to the ESP32-C3 GPIO pins and can control which direction of lights are lit, what brightness, and can switch it so fast it looks like both sets are lit at the same time.
- 2 way Christmas light splitter, which I cut up, the male end to plug in to the power and the 2 female ends to attach to my lights, because I'm not brave enough to cut them up
- a 31V power adapter that can output enough power for 2 sets of lights, as I want to hook up 2 sets to the same output, but each individual power adapter is only rated for one set.
- A bunch of other stuff, like female headers, prototype board, resistors, etc
Then, programming the ESP32-C3 - I worked out what I wanted based on how some other smart devices work - when you turn it on, it doesn't know your WIFI details, but if you hold a button, it puts it in to Bluetooth mode, you can connect to it and set WIFI details - I'm doing this through a general Bluetooth application that detects the functions a Bluetooth device offers and lets you send raw data to them, it's fiddly but I'm not building an app and only have to do this one.
Once it's on the WIFI, it goes out of Bluetooth mode. Now it advertises itself over mDNS on the network - you can use standard tools on your WIFI network to pick up any services running - it found my Christmas light controller!
Once it's found, you know what it's called - my Christmas lights took the MAC address of the chip and took the last few bytes, as a random identifier - so each controller is something like `http://xmas-lights-1234ab.local` - visit this page and the ESP32-C3 is serving a simple Tailwind webpage that lets you set:
- Mode: On (always on), Off, Schedule
- Schedule: add up to 10 time slots to turn on or off the lights
- Pattern: one of a few patterns - they are small bits of code that take the current number of milliseconds since the microcontroller started and return 2 numbers between 0 and 1. If a pattern is active, it calls the code every millisecond or so and with the result, updates the lights - e.g. 0,0 = both off, 0,1 or 1,0 = one or the other on, 1,1 = both on... 0.5, 0.5 = both on at half brightness - and any combination in between
And then I put the whole thing in a lunchbox with some cable ties, support wood and hot glue. Not pretty, but does the job! And bam, I have a smart controller for my outside Christmas lights!
I'm now working on better patterns, as I only have a few basic ones, but I only really want a subtle tinkle, I'm don't want to be too flashy (pun intended).
In total, I probably spent about £70 on stuff, several attempts to get the soldering right over a few evenings, suffered from 3 DRV8871's that arrived dead or not functioning as they should, which made me question my soldering and circuit layout, with multimeter probing to try and track down the issues and eventually I accidentally shorting 31V in to one ESP32-C3 and killed it. So it wasn't all plain sailing.
Thought this post was a bit different from your standard DIY post.. But still DIY nonetheless and wanted to show it off because I'm kind of proud I actually got it working š
AI disclaimer: Claude helped me layout the protoboard in a good way, as well as helped me write some of the ESP32-C3 code. I'm not an electronics buff, so it was very helpful there. I am a software engineer and could have worked out the code myself, it isn't by any stretch complex, but I don't have much free time to build things like this, so if something can make it quicker, I'll take it.