Be the house in the neighborhood that puts on the light show! Blink your decorative lights to the beat of music and play it on the radio.
So it all started a few years back, when I discovered YouTube video of people that had put up Christmas lights, and had them blinking in sequence to music. It sure lit a fire within me to figure out how it was done. So after some research, I found that there are many ways to get this accomplished. So I decided to choose option is least expensive and at the same time I get to learn the ins and outs of the implementation. I always believe knowledge gained is waste if not shared. So in this blog I will explain how I accomplished this project.
About the Project
Synchronize lights to ANY music using Raspberry pi.
Components used
- Raspberry Pi 3.
- USB WiFi Adapter.
- 8 Channel Relay Module
- FM Transmitter
- Jumper Wires (Female to Female, 1 Pin to 1 Pin).
- Power Strip.
- Duplex outlets.
- 3 Gang outlet box.
- Wire nut wire connectors.
- 14 gauge wire.
- wire stripper.
STEP 1 : Setting up Raspberry pi.
1. Download Raspberry Pi Raspian
2. Convert the image so that you can burn it onto your micro SD card. I like to use Etcher.
3. Enable SSH by doing the following
cd /Volumes/boot
touch ssh
This will enable the SSH to connect remotely.
STEP 2 : Installing LightshowPi on Raspberry Pi
- Update the Pi software.
sudo apt-get update
sudo apt-get upgrade
- Download LightSHowPi
# Install git (if you don't already have it) sudo apt-get install git-core # Clone the repository to /home/pi/lightshowpi cd ~ git clone https://togiles@bitbucket.org/togiles/lightshowpi.git # Grab the stable branch cd lightshowpi git fetch && git checkout stable
Install LightShow Pi
Install the LightShow Pi by navigating to the home directory of your code.
cd /home/pi/lightshowpisudo
./install.sh
Make sure to restart to Pi after the install. The install might take while make sure to get a cup of coffee for your self.
sudo reboot
STEP 3 : Connect relay to Raspberry Pi
It’s time to get some connection completed b/w Pi and 8 channel relay. Make sure to shutdown the Pi before performing the connection. Please follow the diagram shown below in making the connection b/w Pi and Relay.
Now comes the moment of truth. Testing the connection b/w Pi and Relay. Turn on the Pi and SSH into Pi. Navigate to folder LightshowPi and execute the below commands.
cd lightshowpi
sudo python py/hardware_controller.py --state=flash
The above command should make the Relay Led flash for a second. Now that we have confirmed all the Leds are flashing , its time to test an mp3 file. LightShowPi already comes with few sample mp3 files to test. SO execute the below command to test the music file.
sudo python py/synchronized_lights.py --file=/home/pi/lightshowpi/music/sample/ovenrake_deck-the-halls.mp3
You should now hear music and also see the led’s on relay flash according to music.
STEP 4 : Connecting Relay to Duplex Outlet.
The duplex have a hot side and are neutral bridged. Make sure to cut the bridge of hot side so that we can use it independently to plug 8 separate christmas lights. The hot side of the duplex has golder screws whereas neutral side has silver screws.
Please follow the connection show below for connecting duplex to relay.
You can use a Four Gang Device Box to pack receptacles in it and use a receptacle wall plate to cover it. You have eight receptacles so you can plug in up to eight 110v lights to the Pi. Just keep in mind that these SSD relays can’t handle too much load so, don’t plug a heavy load into the receptacle.
Now you can either put lights on your Christmas tree or decorate your house with those lights.
STEP 5 : FINAL SHOW DOWN
In this step let’s create a play list and automate the light show for a particular duration using the cron job.
1. Creating a playlist.
a. Create a folder under music directory located under LightShowPi. Example myMusic
> mkdir myMusic
b. Place all the mp3 files you would like in the playlist in the folder myMusic.
c. Navigate to tools folder under lightshiwPi and execute the command
python /home/pi/lightshowpi/tools/playlist_generator.py .This command will ask you for the absolute path of the myMusic folder. Provide the path and press ENTER. This should create a .playlist file under the myMusic folder.
d. Create an overrides.cfg from defaults.cfg. We will now over ride the overrides.cfg file to enable playlist file.
e. Scroll down to the [lightshow] section, comment the default playlist path and add a new one to reflect our music directory. It should look like this:
playlist_path = $SYNCHRONIZED_LIGHTS_HOME/music/sample/.playlist
Change it to
playlist_path = $SYNCHRONIZED_LIGHTS_HOME/music/myMusic/.playlist. Thats it. Save it and close the file. Now test if the new playlist is working:
sudo python /home/pi/lightshowpi/py/synchronized_lights.py --playlist=/home/pi/lightshowpi/music/myMusic/.playlist
STEP 6 : FM Transmitter
If you’re going to have a Christmas light display one of the best parts is having friends, family, and strangers pull up and turn the dial in their cars to hear your display. But if you want your display to be heard then you need to connect a FM transmitter to Audio out of your Raspberry Pi. Please don’t make the mistake of putting up a speaker…you might annoy your neighbors. Here is the FM transmitter I usedfor my project. Click here
Credit where due: This tutorial is a result of immense work done by many individuals. Many thanks to Lightshowpi team that created this amazingly cool open source project.