Introduction: Raspberry Pi Christmas Tree Light Show

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

Step 2: Setup the Raspberry Pi

Before diving into the wiring I wanted to get the Pi up and running first to test out the components as they were connected. This setup was done before the setup the enclosure, and involves the Raspberry Pi connected via USB power to a monitor and keyboard. The goal is to get the system configured to the point development can continue on the Pi in the enclosure.

The default Pi install does not have the the libraries needed to properly drive the WS2801 LEDs in the star so I installed AdaFruit's Occidentalis operating system on the Pi.

After the Occidnetalis install a little extra setup was involved:

1) Configure the Pi to boot to a Command Prompt (not the GUI interface)

2) Setup the wireless network interface on the Pi by editing /etc/network/interfaces. Make sure to pick a static IP address so that you can log-in to a known address to work on the Pi

3) Install Telnet and FTP services.

4) Install Pygame. The library is used in the python scripts for playing MP3/WAV files

Details instructions for the install/setup can be found easily through Internet searches. Plenty of resources exist on the Pi online.

After this point I can disconnect any video out and keyboard because the Pi can be you can logged into remotely.

Step 3: Start Setting Up the Enclosure

I won't go into much details on how to build the enclosure as it is just a box made of wood. I drilled 1.5" diameter holds on the ends of the enclosure. On the right is the hole where all the extension cords and star cord run out and the left is the hole where the power strip and audio out are run.

The first components to mount are the power strip and Raspberry Pi. To power the Pi I am using the same 5V transformer to power the star and Pi (shown in green). Because of this I have the power going to a terminal block (highlighted white) where the 5V forks off to the star wiring and to the Pi

Pin 2 = 5V

Pin 6 = Ground

Once connected up turn on the power and the Pi should boot up and be accessable via Telnet as setup in the previous step.

Step 4: Connecting the Raspberry Pi to the Relay Module

With all Power Off (Power Supplys and Pi), connect the 5 Volts to the bottom two external power source connectors. I drove this with a dedicated 5 Volt supply attached to the power strip. This is so that the Pi doesn't have the entire load of driving the relay (the concern is 8 simultaneous relays engaged) and instead can just drive a transistor to engage external power to the relay.

Now determine the location of the GPIO0 through GPIO7 on the Raspberry Pi. On my B-Model that is:

GPIO0 = Pin 11

GPIO1 = Pin 12

GPIO2 = Pin 13

GPIO3 = Pin 15

GPIO4 = Pin 16

GPIO5 = Pin 18

GPIO6 = Pin 22

GPIO7 = Pin 7

Ground/0V = Pin 6, Pin 9, Pin 14, Pin 20, Pin 25

Since the connection on the SSR Module is screw in posts, I trimmed each jumper to the proper size based on how I was spacing out the components. Connect all 8 input channels as well as ground from the Pi onto the board. Needle nose pliers help to seat the jumpers into the Pi header properly.

Each channel has a LED on the SSR Module that will light when GPIO goes high on the Pi. Run a simple test program to check all of the connections, attached as test.py, where each GPIO0-7 is set high for two seconds.

Step 5: Cut and Prep Extension Cords

On each extension cord cut off the plug end leaving the maximum available length to the socketted end of the cord as it will possibly have to go to the top of the tree. On the cord split the ends of the wire apart by cutting the thin piece of plastic holding the two wires together. Now strip the ends so that about 1/4" of wire is exposed for the screw on connectors.

Use a Sharpie marker on each end socketted end of the cord to write the numbers 1 through 8 so that you can easily identify which socket goes to which channel on the SSR module.

We will also need one plug and also some extra wire for the next step, so either cannibalize a 9th extension cord or leave some extra room on the 8 extension cords when cutting off the plug end.

Step 6: Connecting the AC Extension Cords

Next step hooks the output end of the SSR module with 8 extension cords. Since the amount of wires here can get cluttered very easily I used a power distribution bock and a staple gun to try and keep everything in place.

With power off, take the cut up plug end from the previous step and plug it to the power strip. Strip the other two ends and connect each to the top and bottom power distribution block and staple these two connections down.

Now connect one of the cut up extension cords from the previous step. In my case I have an enclosure with a 1.5" diameter hole for all the cords to flow out, so highlighted in green is one of the cords with one end connected to the distribution block and the other to the output end of the SSR module. To complete the circuit we need a much shorter wire (shown in blue) that connects the other distribution block to the SSR module. Trim and staple to keep everything as neat as possible. Not only does the staple keep things neat but it also serves a strain relief so that any tugging and pulling when connecting the lights to the tree will not pull the connections out of components. Needless to say, when stapling do not have the staple pierce the wire or insulation.

Step 7: Test the AC Hookups

Rather than hook up full strings of Christmas Lights I hooked up cheap $1 night lights to each extension cord to test and develop the animations before the tree was up. I painted the lights connected to the cords that would control the Red, Green, Blue light strings.

Run the same test program used to test the SSR module and ensure each connection lights properly.

The box of lights indicated that each string would draw 0.34 Amps, and for the colored lights I was going to string two sets of together which should result in a total draw of 0.68 Amps. This is well below the rating of the SSR which are 75 - 200 VAC at 2 Amps, however I did want to double check as the fuse on the SSR module is soldered to the board making it difficult to replace.

Step 8: Creating the Star

The first step in creating the star is making a printable template to help shape the wood frame and plastic. After scaling and printing the template at the appropriate size I took a piece of 4.25" x 0.125" wood from the craft store and measured the distance needed for each side of the star. I did not actually bevel any of the joints when I was cutting them so forming the star required support to keep the pieces in place while gluing.

Placing the template down on the work surface I used supports to hold the two pieces of wood in place as shown in brown in the picture. With the two edges of the wood touching, glue was applied on either side of the joint. Then taking a thin piece of balsa I cut out a triangle to mend the two pieces together and glued that onto the star. The reason for using balsa is that once the star is firmly together I was able to easily sand the triangle down to match the contour of the star, shown circled in the image of the star.

Because of the construction method, I had to wait a few hours on each joint for the glue to dry before moving to the next joint.

Once the entire star was formed I use drywall spackle to cover the gaps where two pieces of wood met at the tips of the star.

I then glued in some small stoppers around the inside of the star to help seat the LED assembly in place when inserted, highlighted with a rectangle. I don't believe they are actually necessary as gravity does a job of holding the LED assembly in place.

Laying the assembled star down on top of the Lexan sheet, trace the shape of the star and cut out the star from the Lexan. After cutting the Lexan star, verify that it fits in the wood frame, and then apply 2 coats of white spray paint to one side of the Lexan and allow to dry for 24 hours. This allows the LEDs to be diffused as well as hide them from view.

To hide the cap between the Lexan star and the wood frame I used a small 0.25" strip of balsa wood and cut it to shape and "capped" the frame so that the balsa covered the gap.

Finally added a stick/dowel to help attach the star to the tree top.

Step 9: Create the LED Mounting

Using the same template to form the wooden star, cut out the ABS plastic sheet to size, but slightly smaller to be able to insert inside the wooden star. Test out that it fits well inside the wooden star.

Then still using the template with hole locations, drill the 25 LED holes. The LEDs from AdaFruit have a silicone flange on the outside of them so they mount perfectly into holes drilled at 12mm. In the picture you can see the flange and I've used a green line to indicate where the ABS plastic would engage the flange to hold the LED in place.

Start on one of the tips and work around the outside of the star, then move to the inner 5 mounts to complete the piece. In my program I have the LED positions wired as shown numerically in the picture, with 1 being the first LED after the connector.

Apply some electrical tape to the red and blue ends of the cable. They are secondary inputs for power that we will not use, and instead use the red/blue connection with the clock/signal connection over the cable itself.

Step 10: Creating the Extension Wire for the LED Star

Next is creating a 8 ft cable to run from the enclosure to the star at the top of the tree.

Cut 4 equal length pieces of 8 ft wire and on one end of the cable bundle use either electrical tape or zip ties to keep the bundle together and neat. Do this down the entire length of the 4 cable bundle every couple of inches.

On either end of the bundle strip the wires and solder to the JST connectors so that the wire can connect one end to the enclosure and the other to the star. Being sure to keep the relative position of the wires in the proper order so that when plugged into the star the Blue/Green/Yellow/Red connections match on the other end of the cable. Use a multimeter to check the cable to make sure it is wired properly.

Step 11: Wire the Star to the Pi

We need to now create the receptacle in the enclosure for the star/extension wire to plug into.

Red = 5 Volts

Blue = Ground

So we can wire up these two lines on the JST connector to the terminal block that the Raspberry Pi's power is attached to.

The other two connections are:

Yellow = Data = MOSI = Pin 19

Green = Clock = SCLK = Pin 23

I followed the wiring from AdaFruit's tutorial. So strip the ends of two jumper cables so that they can be soldered onto the JST connector.

Once you are confident that the wiring will get the proper signals to the LEDs, you can stable down the connector in the enclosure for strain relief so that any tugging on the extension cable will not rip the jumpers out of the Pi.

Step 12: Test the LED Star

With the LED star connected to the Pi. Run a simple test program to verify the lighting is working properly. Much of my code is adapted from the AdaFruit Tutorial as well as a forum post on the website about adapting the tutorial code to fit the LEDs we are using..

The attached ledtest.py will have the star slowly turn from pure blue to pure red.

Step 13: Connect the Speakers, Build an Enclosure Top

Nothing special here, just attach the speakers into the audio out of the Raspberry Pi, and plug them into the power strip. An simple powered speaker with a volume adjustment knob will work.

For the top I wanted to be able to look into the enclosure, so I mounted a piece of 8.5 x 11 glass (from a picture frame) to the lid and used Velcro on the top so that I could quickly remove the top if needed. A large portion of the enclosure has 110 VAC exposed so it is important for the top to provide protection from anyone or anything from accidentally making contact.

Step 14: Connect the Lighting to the Tree

I selected the layout of channels on the Christmas Tree to give me the maximum flexibility to generate different kinds of motion/effects. Attached is a picture of how I laid out the lighting for the 5 white strands. The remaining three channels were each a set of two 100 light colored lights: Red, Green, Blue.

The particular extension cord that you plug into each strand is not critical as in the next step I can customize the mapping between GPIO0-7 and what lights are on the tree.

Step 15: Load/Create Music, Software, Sequences....

There are numerous Christmas light sequencers available online for the Raspberry Pi, but I coded a simple one from scratch. All of the sequences were generated by lining up timings of beats/measures in Audacity (audio editor) to particular commands to my sequencer.

rxmas.py

This program will randomly pick a static layout for the tree every minute. I have this script running at startup of the Raspberry Pi (through a cron job) as the default behavior when plugging in the unit.

xmas.py

This is the sequencer program, which takes a sequence file and a MP3 as inputs

setup.txt

In the previous step, I provided the layout I used for each logical channel. This file maps each actual GPIO0-7 to the logical channel. So in the setup.txt I have attached, GPIO0's extension cord drives logical channel 8 (Blue), GPIO1 drives logical channel 6 (Red), etc...

test.mp3 / test.txt

This is a simple test case of a audio count of numbers 1 through 8 with the equivalent light strings lighting up

So to invoke this example type:

./xmas.py test.txt test.mp3

carol.txt

The sequencer file for Christmas Sarajevo by Trans-Siberian Orchestra

LetItGo.txt

The sequencer file for Let It Go from Disney's Frozen Movie

russian.txt

The sequencer file for "A Mad Russian's Christmas" by Trans-Siberian Orchestra

You will have to supply your own LetItGo.mp3 and carol.mp3 files obviously! Just purchase them off Amazon.

NOTE: The embedded YouTube video is sped up to 110% speed so it may sound a little odd

Comments

author
negtrait (author)2016-12-28

Thanks for this project! My kids and I learned a lot!

I created a new .txt sequence file for "Wizards in Winter (Instrumental)" from
Trans-Siberian Orchestra. The .txt file can be found here: https://docs.google.com/document/d/16VYh35OhdqAMxGVJ2Qps6YsggBtffaF4H35ncQueqRQ/edit?usp=sharing

I did all of the sequencing times according to the actual
times in the song, but found that the lights were consistently changing a bit
ahead of the music. I ended up just
adding a delay to xmas.py and then saving that as Wizardsxmas.py and using that
for this song rather that xmas.py.

I added this at line 335:

time.sleep(.65) # a delay for the lights to wait for the
music

https://docs.google.com/document/d/16VYh35OhdqAMxG...

author
drpi (author)negtrait2016-12-28

Just tried your Wizards sequence out and it was great! Nice work. I didn't have an issue with the timing.

author
radibadical (author)2016-10-27

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.

author
TomB73 (author)radibadical2016-12-11

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.

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.

Good luck with the project!

raspchristmas.png
author
PaulL283 (author)TomB732016-12-13

That interface looks great! Any chance you could share it? I have created custom command buttons with webmin, but your way looks much better.

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.

author
PaulL283 (author)PaulL2832016-12-15

Nice work. Thanks for sharing!

author
TomB73 (author)PaulL2832016-12-14

Sure I can share, link at the end of this message.
It's not really 100% finished, but it is about 95% done.

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)

Other than that it should be really easy to use and modify to your needs. Let me know if you have any questions.

The icons are free from here: https://icomoon.io/#preview-free

https://drive.google.com/open?id=0B6VAz5TJ__2SMXlP...

author
BlakeD26 (author)2016-10-27

Is there a maximum number of relays that can be "on" 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.

author
drpi (author)BlakeD262016-12-04

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?

author
radibadical (author)2016-10-30

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?

author
drpi (author)radibadical2016-12-04

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.

author
computerguy721 (author)2016-11-01

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!

author
drpi (author)computerguy7212016-12-04

You load and play the file by calling xmas.py. It would look something like:
python xmas.py test.txt test.mp3

author
kenspratt (author)2016-12-01

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.

author
drpi (author)kenspratt2016-12-04

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.

author
Luke Sell (author)2016-12-02

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?

author
NickS283 (author)Luke Sell2016-12-04

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.

author
YolandaX (author)2016-09-16

Thank you so much for this project. Could you tell me how to make the txt of the music? Thanks again!

author
anna_porter (author)2016-09-12

I am looking at doing this as an end of year project at my school.

I was just wondering what sort of wire do you need for 5. 32ft roll of wire on the control board? And where did you purchase this from?

Thanks,

author
Draleg (author)2016-09-07

Hello, thank you so much for this project !!
I bought an 8 channel relay ( https://www.amazon.fr/SunFounder-Channel-Shield-M... ).
It's work like a charm with my RPi B rev1 .
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?

With Audacity and the tool "Beat Finder" I can generate a text file but not in the MS format like the different sample here...

Some one can help me please ?

Best regards.

author
Joseph Aljets (author)2016-09-06

Do you think that Lightshow Pi would work for sequencing the lights or does anyone have a different idea for the program?

author
phil0871 (author)2016-08-04

Has anyone come up with a faster way to make the timing files?

author
VincentV19 (author)2016-01-08

Good evening how branch t Please order on son of raspberry and sainsmart or the + and - on relay out thank you

author
bikr made it! (author)2015-12-22

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?

image.jpegimage.jpeg
author
bikr (author)2015-12-22

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

author
phil0871 (author)2015-12-07

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?

author
shundal1 (author)phil08712015-12-19

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.

author
phil0871 (author)shundal12015-12-20

I found it! Thanks shundal1. You need to add “dtparam=spi=on” to your config.txt and reboot.

sudo nano /boot/config.txt

add…
dtparam=spi=on

…at the end of the file, save, and then reboot.

author
jasonb7156 (author)phil08712015-12-15

Phil,

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.

Is there anyway of determining if the strand is damaged?

Any help is appreciated!

Thanks,
Jason

author
Osprey22 (author)jasonb71562015-12-15

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.

author
phil0871 (author)Osprey222015-12-18

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.

Wiring.jpg
author
phil0871 (author)jasonb71562015-12-17

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.

author
shundal1 (author)2015-12-19

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.

author
abrown530 (author)2015-12-06

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!

author
AlexW58 (author)abrown5302015-12-15

Did you figure out your problem I am having the same problem

author
phil0871 (author)abrown5302015-12-07

Do you have power hooked up to the distribution blocks as shown in yellow in this picture?

FGRN8IUI27GS1LY.MEDIUM.jpg
author
jasonb7156 (author)2015-04-19

author
Osprey22 (author)jasonb71562015-04-19

In test.py you'll see it lists out the channels as
11,12,13,15,16,18,22,7
but then in xmas.py it is pin_map array at the beginning that defines it as
11,12,8,15,16,18,22,7

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.

author
jasonb7156 (author)Osprey222015-04-20

Thank You Sir. That was an easy one! Now to tackle the start...!

Hey do you think you are going to program more songs for this coming holiday?

author
Osprey22 (author)jasonb71562015-04-21

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.

author
obstler (author)Osprey222015-12-12

hi, thanks for the great instructions! any chance wizards in winter or another song is ready for this year?

author
jasonb7156 (author)jasonb71562015-04-19

Messed up my prior post..uggh

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.

author
PeterS21 (author)jasonb71562015-05-01

I started reading through xmas.py and the pin_map array had "8" instead of "13". I made the change and xmas.py is now triggering GPIO2/Channel 3.

Now, off to buy some more supplies so I can tie lights into the relay!

Thanks for such a fun project tutorial.

author
PeterS21 (author)jasonb71562015-05-01

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.

author
MatthewS126 (author)2015-11-27

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:

GPIO2 - Channel 1

GPIO3 - Channel 2

GPIO4 - Channel 3

GPIO5 - Channel 4

GPIO6 - Channel 5

GPIO7 - Channel 6

GPIO8 - Channel 7

GPIO9 - Channel 8

Then the GND pin on the relay I have connected to a GND on the Pi (Pin 30)

Any advice would be taken with widely open ears, thanks.

author
CamCroz99 made it! (author)MatthewS1262015-11-28

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.

GPIO_Pi2.png
author
MatthewS126 (author)CamCroz992015-11-28

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..

_________________________________________________________________

GPIO.setup(pin_map[i], GPIO.OUT)

Traceback (most recent call last):

File "xmas.py", line 300, in <module>

GPIO.setup(pin_map[i], GPIO.OUT)

IndexError: list index out of range

_________________________________________________________________

I noticed someone further down had at least one of these errors, but any help on how to solve them would be great, thanks.

author
CamCroz99 (author)MatthewS1262015-11-28

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.

author
farleylives (author)2015-11-02

Question from an absolute newb here. Believe me, I know this is probably going to be easy to answer but I'm clueless.

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?

author
MatthewS126 (author)farleylives2015-11-26

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&redirect=true&ref_=oh_aui_detailpage_o00_s00

About This Instructable

193,886views

448favorites

License:

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