Christmas Lights AC Controller Tutorial
I'm doing a Christmas light show to music this year and I thought I'd share various resources that I slowly pulled together about creating fancy light shows
My DIY Enclosure
I wanted an enclosure that could switch A/C lights and also run a decent amount of pixels. This is my solution - it has 8 AC power cords it can switch, and the two ESPixelSticks should be able to run up to 680 pixels each for 1360 total addressible RGB LED lights.
12 position Screw Terminal Blocks - Amazon
Spade connectors 18-22AWG - Amazon
SainSmart 8-Channel Solid State Relay - Amazon
1 ft Power Cords - Amazon
Plastic Waterproof Cable Glands assorted sizes - Amazon
16AWG 4-conductor Speaker Wire - Amazon
CableGuard CG-1500 Enclosure - WiredWatts
5V 350W DC Power Supply - WiredWatts
ESP8266 module and adapter - Amazon
5V Power Supply and 120VAC input
The first priority was getting power to the 5V power supply that would run the pixels. I used power rails from amazon so that I could put each wire from the AC source on each rail, then ran another wire from the rail to the 5V power supply. As you can see I labelled each terminal block with the neutral on the left, ground in the middle, and live/hot on the right. I put hot on the right because my relay module will also be on the right and you want to switch the hot wire using the relays.
I used a cable gland to secure the cable. The cable gland screws on both sides of the plastic enclosure and the cable goes through it, then you tighten a nut which tightens down onto the cord and holds it in place. This should be water-tight and strong enough to withstand occasional tugs.
As you can see in the image above, I used the screw terminal blocks as bus bars for each individual AC channel. The relay should switch the HOT line on/off so that when the relay is off the wire should not be energized.
Wiring and Programming the Arduino Mega
I used a Mega because I already had the Mega attached and wired to the relay module - you don't need the full mega if you're only controlling 8 relays!! If you want to expand this and use more than 16 relays you'll need the extra outputs on the mega, but you can use an Uno for this and it will take up less space. Here's a wiring diagram of what I did - I powered the ESP8266 with the 3.3V out from the Mega. The Mega is supplied by the 5V from the power supply for my RGB lights so I put the 5V on the 5V pin. If you're powering it from 12V put the 12V into the Vin pin which uses the internal voltage regulator to step it down to 5V and 3.3V.
The code I used in the Arduino can be found below or here:
Note: This receives output from the GPIO2 pin on the ESP8266 module. NOT THE TX PIN!!! (RIP those 2 hours of my life)
Flash your ESP8266 with the most recent firmware following this tutorial, and when you can select the mode between WS2811 or Renard do Renard.