This project involves using a Raspberry Pi to drive 8 AC outlets which are connected to Christmas Tree light sets. The AC lights are simple one color strands of lights, but to give a more dynamic range to the light show there is also a 25 programmable RGB LED star. One of the benefits of using the Raspberry Pi instead of an Arduino controller is that I can drive the audio out of the Raspberry Pi to have the lights timed with music (not to mention the benefit having a WiFi connection to work on the software remotely).

Step 1: Materials

Keep in mind the materials below are what I used for this project. In many cases alternate parts/solutions can be used.

Here are the materials I used for this project:

For the controller:

  1. Raspberry Pi (B Model is what I used)
    • SD Card
    • USB Wifi Adapter
  2. SainSmart 8 Channel 5V SSR Module Board - Amazon
    • I avoided the mechanical relays as the clicking sound of the switch will be noticeably audible, and went we SSRs. This board is rated up to 2 AMP per SSR which is enough for powering a string of Christmas lights
  3. Jumper wires - Can be found cheap on Ebay
  4. JST SM Plug + Receptacles - Adafruit
  5. 32ft roll of wire (or four 8 ft pieces of wire)
  6. Extension Cord x 8
  7. Power distribution block x 2 - AdaFruit
  8. Power Strip
  9. Power Supplies
    • 5 Volts, 3 Amps or greater to drive LEDs and Pi
    • 5 Volts, 1 Amp or greater to drive SSR module
  10. Enclosure
  11. Speakers

For the star:

  1. 12mm RGB LEDs (Strand of 25) - AdafruitWS2801 chip in this product allows the Pi to just have to pulse the strand once rather than continuously pulse the line to keep the LEDs illuminated.
  2. Plastic ABS Sheet to hold LEDs in place - Walmart
  3. Lexan sheet to diffuse LEDs - Lowes
  4. Black Spray Paint
  5. White Spray Paint
  6. Wood

For the tree:

  1. White 100 light strand x 4
  2. White 50 light strand
  3. Red 100 light strand x 2
  4. Green 100 light strand x 2
  5. Blue 100 light strands x 2
<p>Thanks for this project! My kids and I learned a lot!</p><p>I created a new .txt sequence file for &quot;Wizards in Winter (Instrumental)&quot; from<br>Trans-Siberian Orchestra. The .txt file can be found here: <a href="https://docs.google.com/document/d/16VYh35OhdqAMxGVJ2Qps6YsggBtffaF4H35ncQueqRQ/edit?usp=sharing" rel="nofollow">https://docs.google.com/document/d/16VYh35OhdqAMxGVJ2Qps6YsggBtffaF4H35ncQueqRQ/edit?usp=sharing</a></p><p>I did all of the sequencing times according to the actual<br>times in the song, but found that the lights were consistently changing a bit<br>ahead of the music. I ended up just<br>adding a delay to xmas.py and then saving that as Wizardsxmas.py and using that<br>for this song rather that xmas.py.</p><p>I added this at line 335: </p><p>time.sleep(.65) # a delay for the lights to wait for the<br>music</p><p><a href="https://docs.google.com/document/d/16VYh35OhdqAMxGVJ2Qps6YsggBtffaF4H35ncQueqRQ/edit?usp=sharing" rel="nofollow">https://docs.google.com/document/d/16VYh35OhdqAMxG...</a></p>
<p>Just tried your Wizards sequence out and it was great! Nice work. I didn't have an issue with the timing.</p>
<p>Thanks for this project. I also would like to know how I can produce the .txt file...I might just make a spreadsheet in excel and export as a CSV...Is that the best way? A template would be useful.</p>
<p>I've done this project last year, very happy with the results. I have tried making my own sequences, but it turned out to be such a pain, I couldn't even finish one song. I was using Audacity to read the mp3 and to help time the light sequences to the music, I then used a spreadsheet to write the actual commands for the lights and export that as csv, it worked fine but like I said it was just too much pain to do one song. I think it was taking me about one hour to do about 20 seconds of the sequence. Maybe you someone else has come up with a better way.</p><p>I did create a web interface for this project however, so I can control all the lights and the pi from any device on my local network as long as it has a browser.</p><p>Good luck with the project!</p>
<p>That interface looks great! Any chance you could share it? I have created custom command buttons with webmin, but your way looks much better.</p><p>I am running two of these systems. One on the tree that I put together last year. This year, I connected another to my lawn decorations. Next year, I plan on increasing that to 16 channels.</p>
<p>Nice work. Thanks for sharing!</p>
<p>Sure I can share, link at the end of this message.<br>It's not really 100% finished, but it is about 95% done. </p><p>To take advantage of the reboot/shutdown options I believe you will need to give apache elevated permissions, the /data/ folder contains all the executable files to run various commands (reboot/shutdown included) </p><p>Other than that it should be really easy to use and modify to your needs. Let me know if you have any questions.</p><p>The icons are free from here: https://icomoon.io/#preview-free</p><p><a href="https://drive.google.com/open?id=0B6VAz5TJ__2SMXlPT0N5MFpFZEE" rel="nofollow">https://drive.google.com/open?id=0B6VAz5TJ__2SMXlP...</a></p>
<p>Is there a maximum number of relays that can be &quot;on&quot; at one time? Whenever I try to make my own .txt files, all of the lights go off if I try to trigger 5 relays at the same time. I seems like 4 is the maximum.</p>
<p>Did you purchase the relay suggested here? There is no limitation as far as I am aware. I've definitely had all 8 channels of the relay on at once. Perhaps you got a faulty one?</p>
<p>Am I not reading this wiring diagram correctly? I have my 110 plug split between the 2 busses that takes up one of the 7 termination slots on each bus. I now have 6 remaining termination slots on each, which allows me to wire up 6 extension cord circuits...I am short 2? What am I missing here?</p>
<p>Some of the terminals will have multiple wires under the screw. I'm not an electrician though so consult one if you're not comfortable.</p>
<p>How do you actually load and play the file? Also, how is the music sequenced, and the file timed with the mp3? The final step seems like more a list rather than instructions. Could you clarify? Thanks!</p>
<p>You load and play the file by calling xmas.py. It would look something like: <br>python xmas.py test.txt test.mp3</p>
<p>Has anyone actually made this in the past 6mos? I can't find all the software and that which I have found is out of date and doesn't work. Ugh.</p>
<p>I've recently gone through this whole process (within the last few months). What exactly are you having issues with? Pretty much all you need as far as software is the OS and pygame, both of which are redily available. </p>
<p>It's getting kind of expensive to fix this every time I try to start it up. I used the 115 to power everything since it is right there in the box. Apparently the Pi doesn't work right since it catches fire and stops working pretty quickly. Also set the tree on fire one time, that cost an extra $50 too. Should I use different power supplies?</p>
<p>make sure wiring is correct and check amperage in each channel. Use fuses on the 115 side if you are just unsure. Pi should be isolated however if the SSR fails they typically fail 'closed' which is why I recommend the fuse. Do not string together more than the recommended amount of lights to each channel. Try testing with a simple setup as osprey has done in step 7 to measure amperage before placing on Christmas tree. If you are the slightest unsure have a electrician check your work before connecting mains, electricity is no joke. </p>
<p>Thank you so much for this project. Could you tell me how to make the txt of the music? Thanks again!</p>
<p>I am looking at doing this as an end of year project at my school. </p><p>I was just wondering what sort of wire do you need for <em>5. 32ft roll of wire</em> on the control board? And where did you purchase this from?</p><p>Thanks, </p>
<p>Hello, thank you so much for this project !!<br>I bought an 8 channel relay ( https://www.amazon.fr/SunFounder-Channel-Shield-M... ).<br>It's work like a charm with my RPi B rev1 .<br>I have a question, how can I generate a timestamp file format in MS from start to end of a mp3 file to add after the commands of the relay?<br><br>With Audacity and the tool &quot;Beat Finder&quot; I can generate a text file but not in the MS format like the different sample here...<br><br>Some one can help me please ?<br><br>Best regards.</p>
<p>Do you think that Lightshow Pi would work for sequencing the lights or does anyone have a different idea for the program?</p>
<p>Has anyone come up with a faster way to make the timing files?</p>
Good evening how branch t Please order on son of raspberry and sainsmart or the + and - on relay out thank you
So here's my creation. I think I'm going to rotate the outlet bar 90 degrees not sure why I felt the current setup was the best route lol. That being said it's pretty clean. Need to tidy up the jumper wires to the Pi and cut down the house and encase it all . Thoughts?<br>
<p>Hi there! Great project. I'm just about finished my setup (just need to mount it and actually wire the relays to something (I bought outlets) Curious , how are you having the xmas.py run, are you doing it on a cron job every 10-15 minutes? I was thinking maybe I'd have a bash script that lights all of the relays up (gpio write 1) and then cron the python every 15 minutes or so. Is this how you did it too? Rather than having to login and do it manually</p>
<p>I have everything working except for the star. I am using the same Adafruit WS2801 leds as in the tutorial and am running Occidentalis v0.2 on a B+. I have double and triple checked my wiring and dont think thats the issue. Is there additional setup required on the Pi to control the star?</p>
I had the same issue, eventually I found a solution that had to do with something they changed in how the spi is handled. I followed instructions on how to disable this and it startrd working. Unfortunately i forgot to bookmark the page so I have no idea where to point you to.
<p>I found it! Thanks shundal1. You need to add &ldquo;dtparam=spi=on&rdquo; to your config.txt and reboot.</p><p>sudo nano /boot/config.txt</p><p>add&hellip;<br>dtparam=spi=on</p><p>&hellip;at the end of the file, save, and then reboot.</p>
<p>Phil,</p><p>I am having the same issue with getting the star to work. The first LED on the WS2801 strand lights up a light blue but nothing else happens. I have confirmed the wiring is correct, and also confirmed the Pi is connected to the input end of the strand. </p><p>Is there anyway of determining if the strand is damaged?</p><p>Any help is appreciated!</p><p>Thanks,<br>Jason</p>
<p>I actually had the same issue initially until I realized that the ground of the LED strand needed to be tied to the ground of the Raspberry Pi. One I did that the entire strip lit up. Not sure if you are running into the same issue with your wiring, but thought I'd throw it out there. </p>
<p>I tried tying in the ground as you suggested but I am still getting just 1 LED, and it does not change color when I run the programs. Here is a diagram of my wiring, I don't know what I'm doing wrong.</p>
<p>That is exactly what I am getting. I was about to contact Adafruit and see if I had a bad strip of LEDs. I am going to give Osprey's suggestion a shot and see if it helps.</p>
Has anyone had issues when attaching the LED star via the 8 ft extension? I have it working perfectly when testing, connecting dirrctly to the JST connector that plugs inti the Pi. However, when I connect using the long cable with JST connectors on either end, the star starts freaking out. It gets the right signal for the most part, but during blinks it flashes random colors and frequently gives the wrong colors.
<p>I'm on step 6 and 7 right now. I am only using 4 extension cords (with test bulbs on the end of them) so I powered each relay from one distribution block, and wired the extension cords to the other distribution block. I then used the other ends of the extension cords and wired them to the 4 relays. For some reason, the 4 extension cords test bulbs are not lighting up. Anyone have any suggestions? Thank you!</p>
<p>Did you figure out your problem I am having the same problem</p>
<p>Do you have power hooked up to the distribution blocks as shown in yellow in this picture?</p>
In test.py you'll see it lists out the channels as <br>11,12,13,15,16,18,22,7<br>but then in xmas.py it is pin_map array at the beginning that defines it as<br>11,12,8,15,16,18,22,7<br><br>So looks like my test.py and xmas.py don't quite line up. But all you need to do is change that 8 to a 13 in pin_map in xmas.py and sounds like it should work.
<p>Thank You Sir. That was an easy one! Now to tackle the start...!</p><p>Hey do you think you are going to program more songs for this coming holiday?</p>
<p>I think so. I know I wanted to Wizards in Winter by Trans-Siberian Orchestra last year but couldn't get to it, so that'll probably be at least one new one. Also I did manage to make an update to have the Christmas tree function as a grandfather clock, and gong with a simple animation on the hour, which I'll probably post when I take everything out for Christmas.</p>
<p>hi, thanks for the great instructions! any chance wizards in winter or another song is ready for this year?</p>
<p>Messed up my prior post..uggh</p><p>I enjoyed making this project and it works great. However, i can't get channel 3 to fire for any of the songs. I have verified it works by running a test.py program, but can't figure out in your code what the issue is. Any help would be very much appreciated.</p>
<p>I started reading through xmas.py and the pin_map array had &quot;8&quot; instead of &quot;13&quot;. I made the change and xmas.py is now triggering GPIO2/Channel 3. </p><p>Now, off to buy some more supplies so I can tie lights into the relay! </p><p>Thanks for such a fun project tutorial. </p>
<p>I'm working on testing my setup and I am having the same problem as Jason. I can run test.py and all 8 relay channel LED's light up in sequence. But when I run xmas.py with test.txt or the two songs, it does not light up Relay 3 (GPOI 2). The other 7 channels light up - and it looks awesome with the songs. </p>
<p>I am at the stage of connecting the Pi to the relay. I am using the same relay as in this tutorial, but am using a Pi2 B model. I can't seem to wire it properly. I have tried using the test program to try and get them to work through trial and error, however the LEDs on the relay for channels 1 and 2 are permanently on (I suspect due to my incorrect wiring). The way I have it wired now:</p><p>GPIO2 - Channel 1</p><p>GPIO3 - Channel 2</p><p>GPIO4 - Channel 3</p><p>GPIO5 - Channel 4</p><p>GPIO6 - Channel 5</p><p>GPIO7 - Channel 6</p><p>GPIO8 - Channel 7</p><p>GPIO9 - Channel 8</p><p>Then the GND pin on the relay I have connected to a GND on the Pi (Pin 30)</p><p>Any advice would be taken with widely open ears, thanks.</p>
<p>Which wiring diagram did you use to connect the relays to the GPIOs on the board? I had this issue and am wondering if you made the same mistake I did. Element 14's Pi2 diagram worked for me as the pin maps have changed over the models.</p>
<p>Yeah thanks, I used this diagram and got it working. I had to use a different test program as for some reason the one in this tutorial din't work for me. I edited the setup.txt to contain the pins I am using (35,37,7,29,31,26,24,21) and I did the same for the line in xmas.py (pin_map = ...). However, I am getting errors..</p><p>_________________________________________________________________</p><p>GPIO.setup(pin_map[i], GPIO.OUT)</p><p>Traceback (most recent call last):</p><p> File &quot;xmas.py&quot;, line 300, in &lt;module&gt;</p><p> GPIO.setup(pin_map[i], GPIO.OUT)</p><p>IndexError: list index out of range</p><p>_________________________________________________________________</p><p>I noticed someone further down had at least one of these errors, but any help on how to solve them would be great, thanks.</p>
<p>When I had this issue it was an issue with my songfile.txt. If you are using different pins then that is probably your issue. It is trying to work with the pinout provided by Osprey22 but those pins have been changed.</p>
<p>Question from an absolute newb here. Believe me, I know this is probably going to be easy to answer but I'm clueless.</p><p>What are you using to connect the terminal block to the GPIO? Just a jumper or electrical wire? If electrical wire, where do I get just a connection piece for the GPIO?</p>
<p>Its a jumper wire, the female connectors are the ones that connect to the GPIO. I got a set with all 3 possible configurations, just in case! http://www.amazon.co.uk/gp/product/B00L2X1X9Q?psc=1&amp;redirect=true&amp;ref_=oh_aui_detailpage_o00_s00</p>

About This Instructable




More by Osprey22:Arduino Controlled Positional RGB LED Christmas Tree Arduino LED Strip Crib/Bed Night Light Raspberry Pi Christmas Tree Light Show 
Add instructable to: