Raspberry Pi Light Controller

1 Overview

The Raspberry Pi is an extremely capable development board, especially with its built in GPIO capability. Coupling the Raspberry Pi GPIO to solid state relay boards makes for an easy way to control Christmas lights. This page provides some basic details of how this project was completed, and will be updated as questions are asked about the project.


figure IMG_20130102_203653_809.jpg figure IMG_20130103_222158_722 - Copy.jpg

2 Links

Please visit the following links for a setup tutorial, and several videos of the light controller.

http://goo.gl/eoKwy8 — Setup Tutorial
http://www.youtube.com/watch?v=RN3Jp2riyHs — Build Pictures
http://www.youtube.com/watch?v=blwvLWsfNGs — Sequence Test
http://www.youtube.com/watch?v=adeC2PapTi0 — Real Time Control From Vixen

3 Prerequisite Files

The source files for the python scripts are available below. Please remember to configure the IP addresses for your network, and also check the location of the Vixen log file.

https://googledrive.com/host/0B6UI0f-tde55cnlPYnBoTzVCMFk/filewatcher.py
https://googledrive.com/host/0B6UI0f-tde55cnlPYnBoTzVCMFk/server.py

4 Standard Disclaimer

Electricity can be dangerous. If you don’t know what you are doing, find someone who does before you accidentally hurt yourself or someone else. No claims of suitability or warranty are made concerning the ideas presented.

5 Hardware

The Raspberry Pi handles all of the computing. The relay board of choice was a Sainsmart 8 channel solid state relay board. This relay board is available from many internet sites, to include the manufacturer. It was chosen for its ease of use. A point of note is that this relay board contains zero cross relays. Zero cross relays “round” the AC waveform to the nearest zero crossing to switch the output on or off. This makes AC dimming difficult. As is discussed in the software section, dimming of incandescent bulbs is still somewhat possible, but random cross relays should be used for better dimming of incandescent bulbs. If precision dimming is necessary, consider digital pixels or DC light strings over AC light strings. Also note that this SSR board has limited power handling capability.

figure Hookups.png

6 Software

6.1 Light Sequencing Software

Many commercial and free solutions exist for the sequencing of Christmas lights. After setting out to write a custom GUI for sequencing, I discovered that it had already been done with the free solution Vixen lights. They have a few versions, but version 2 was used for this project. It has an output to log file option, which was used to send data to the Pi for output.

http://www.vixenlights.com/

6.2 Vixen Configuration

No stock solutions exist for outputting Vixen lights to the Raspberry Pi. A python script was written to monitor the output of the “Event Data Logger” plug-in. The Event Data Logger must be enabled in Vixen for this script to work. Viewing the log should provide the location the file defaults to, and the default name of the log file. These should be entered in the filewatcher.py script, in order for it to read from Vixen.

figure Event Data Logger.png

6.3 Python Script to read the log file — filewatcher.py

A python script was written to read the output of the log file, and send it to the Pi. It is available above under Prerequisite Files, named filewatcher.py. As noted above, please enter the location of the log file from Vixen, in order for this to work. A default name and path are included in the file, but this may be different on your system. Please see the code in the file to determine where to enter this information. Also, the server on the Raspberry Pi must be running for this file to execute properly, and all IP addresses set correctly in the code.

6.4 Python Script for the Pi — server.py

The script called server.py should be run on the pi, in order to receive the data from filewatcher.py. This script receives the intensity values from filewatcher.py, and outputs them to software PWM through wiringPi. The values were chosen to be 0 to 60, in an effort to switch on a scale relative to 60 Hz. This seemed to improve the dimming capability of the system, but your mileage may vary. Remember to run the script with sudo on the Pi.

7 Final Product and Conclusions

figure finished.png
The plywood mounting surface was cut to fit in a plastic container, allowing the unit some protection from the elements. Overall, the project was a success, allowing 16 channels of light control. Although full dimming cannot be achieved, it still produces an effective fade. Although successful, I would likely choose digital pixels over incandescent in the future.