DIY Musical Xmas Lights for Beginners With Raspberry Pi

by MakinThings in Circuits > Raspberry Pi

23202 Views, 76 Favorites, 0 Comments

DIY Musical Xmas Lights for Beginners With Raspberry Pi

DIY musical Xmas lights for beginners

Today, I'll go through the steps to use a raspberry pi to get your Christmas lights flashing with music. With just a few bucks of extra material, I walk you through converting your regular Christmas lights into a whole-house light show. The goal here is to go from scratch. Although this guide is intended for people who don't know how to use linux at all and those who do alike, the focus is for people for whom linux and the raspberry pi are a complete mystery. There is much more that can be done with the lightshowpi software and more sophisticated hardware, but this is about just getting started.

Material

material.png

First the must have:

Temporary needs: this is temporary so I would recommend just using whatever you already have for the few hours it will be needed

  • A USB mouse and keyboard
  • Access to an HDMI monitor or TV
  • A USB hub if switching between mouse and keyboard are too annoying and your other USB ports are occupied

Optional

Setting Up the Pi 1: Installing Raspbian

noobs.png
noobs install.png

The first step is to get raspbian on your device. I will cover all of these in a single block, and cover the hardware separately.

I recommend downloading noobs from the pi foundation https://www.raspberrypi.org/downloads/noobs/

Just unzip, and copy over to your freshly formatted micro SD card. That's it. Once you turn on your pi, it will guide you through the installation.

Setting Up the Pi 2: Setup SSH and VNC

passwrod change.png
turning on ssh.png

Having SSH and VNC setup means you won't need to keep the pi plugged in to a huge mess of wires. Everything will be doable from 2 windows on your laptop or even from your phone. We will often precede our commands with "sudo", this essentially gives our command the administrator privileges.

  1. First change your password. Open a terminal window and type the following and you will be prompted to enter the default password (raspberry) and then put in your own password.
    • sudo passwd
  2. now copy your IP address with the following command
    • ifconfig

Now go to the settings menu, and turn on the SSH and VNC. You can now reboot the pi and unplug it from the monitor, keyboard, and mouse.

Setting Up the Pi 3: Use Bitvise SSH to Access Your Pi

bitvise.png

I recommend bitvise because it has an integrated SFTP tool, as well as a good interface. Enter your IP address you copied over earlier, use the username pi, and your new password. Keep the default port (22). The terminal should open when you select login.

Setting Up the Pi 4: Update Your Pi

Before you do anything else, run the updates

  1. First, you update the library of what packages are available with
    • sudo apt-get update
  2. Once its done running, you actually install the updates with
    • sudo apt-get upgrade

  3. For good measure, make sure your pi firmware is up to date (this should already be done through upgrade)
    • sudo rpi-update

Setting Up the Pi 5: Installing Lightshowpi

installing lightshow.png

This part of the steps is available directly on the lightshowpi website. I will include them for convenience. I will add a few explanations in there.

  • sudo apt-get install git-core
    • apt-get is what gets the packages, and here we will install git-core, dependencies (programs git-core needs to run) will automatically be added
  • cd ~
    • cd is to change directories, while ~ means /home/*username*/, in this case it would be /home/pi/; using that or ~ should work just the same
  • git clone https://togiles@bitbucket.org/togiles/lightshowpi.git
    • That just copied over the folder structure we need
  • cd lightshowpi
    • now we move over to the folder we just downloaded
  • git fetch && git checkout stable
    • now we get the needed files
  • cd /home/pi/lightshowpi
    • we move over to the correct folder; in linux, unless we create system links, we always have to move over to the correct folder before launching scripts
  • sudo ./install.sh
    • this does the actual installation; this took about 3 hours on my pi zero w
  • sudo reboot
    • now we reboot!

Wiring Your Stuff

wiring.png

However you end up powering your devices depends on what you are using. There are many options here, but at the end of the day, you will need 5v for your pi, either through a USB, or using the header pins and a custom power solution like I did. All the power you are interrupting should be DC. AC line voltage will work just fine, but it brings along extra risk. Low voltage is far safer.

Wiring Your Stuff 2: Soldering the Pins

solering.png

If you are using a pi zero, you will either have to solder header pins, or solder the wires directly at the pin holes themselves.

Wiring Your Stuff 3: Connecting the Pi to the Relay Board

j8header-zero.png
relay wires.png

We are using the wiringpi pin numbering. There is an alternative naming convention out there, just use the chart I provided, or go to wiringpi.com

From the relay board, with the pins towards your, from left to right, you will connect to the following on the pi

  1. pin 20: ground
  2. pin 11: GPIO 0
  3. pin 12: GPIO 1
  4. pin 13: GPIO 2
  5. pin 15: GPIO 3
  6. pin 16: GPIO 4
  7. pin 18: GPIO 5
  8. pin 22: GPIO 6
  9. pin 7: GPIO 7
  10. pin 4: 5v power

If you are powering your pi from the header pins, then the +5v will go to pin 2, and the - (ground) will go to pin 6.

Wiring Your Stuff 4: Wiring Your Relays

05_46_1_grande.jpg
relay wires 2.png

The relays work like a switch. However you would wire your lights directly to your power, do that, but then cut the live wire and put each end of that cut wire on one of the relays. Each relays have 3 terminals. 2 of them are together, and powering the relay separates them, the other one becomes connected to the center terminal when the relay is powered. The little diagram of a corner shape shows you which one is separate (in red). The opposing ends (first and last) of each relay will never be connected. If you want, you can do always-on and use the 2 in the green, it just means the lightshowpi commands will be in reverse. It might be useful if you want the lights to default to on after the music ends.

Test It

resting lightshow.png

I used these little LEDs to test my board, but really you can just look at the red light that is on the relay board. Each relay already has its own LED.

  • Don't forget to navigate to the lightshowpi folder first
    • cd /home/pi/lightshowpi/
  • Then use one of these test commands
    • sudo python py/hardware_controller.py --state=flash
    • sudo python py/hardware_controller.py --state=fade
  • To end the test, use CTRL+C

Enjoy!

lightshowpi_thumb.jpg

Now it's time to setup your actual christmas lights, and enjoy the show. Don't forget to check out my full video!

To run your first song, use the demo file provided by the lightshowpi devs

sudo python py/synchronized_lights.py --file=/home/pi/lightshowpi/music/sample/ovenrake_deck-the-halls.mp3

To play any other son, just change the name of the mp3 at the end of that command. This is where the sftp feature of bitvise comes in; you can simply click and drag your files.