PiLight

Recently, my friend shared a link on Facebook about some dudes who’d made their own infinity table. While I don’t necessarily have the time or dedication to build an actual table, I was intrigued by the idea of running an LED string using a Raspberry Pi. And so, one impulse purchase and a few days of development later – I had built PiLight!

In short, PiLight is the software that I came up with to configure and run my lights. PiLight is a Django (Python web-framework) application, so naturally there’s a web-based interface for tweaking the settings. This is a nice solution, because it means that you can configure the lights from literally any device that has a web browser – your phone, tablet, computer, etc. You can read more about how to download and install PiLight on the project page, so this blog post will focus instead on my own end-to-end experience with setting up the Raspberry Pi and getting PiLight working. You can follow it as an informal (but very detailed) guide to doing something like this yourself.

Introduction

I had originally intended to run PiLight as a “standalone” application on the Raspberry Pi, so that the Pi would handle everything, from powering the configuration interface, to driving the LEDs. However, once I got it working, it became evident that the little ARM processor in the Pi just wasn’t quite cut out to perform the amount of processing I wanted it to. While it worked fine, if I added complex animations, the update rate would drop to a point where it was very noticeable (<10fps).

Thus, I decided to build a client/server model for PiLight… PiLight itself would run on a more powerful “server” computer, and the Pi essentially becomes a super thin client that just pipes color data from the server, directly to the LEDs without any processing. This turned out to work really well, and greatly simplifies the installation process on the Pi. As such, I’ll describe this process below.

The hardware

Here’s a list of hardware that I purchased, and my thoughts after getting everything set up:

All together it ran me about $200. You could save around $100 by dropping the WiFi module, purchasing only what you need from the starter kit items, and soldering everything together.

Setting up the server

Because I was developing PiLight on my desktop PC, when it came time to hook up to the Raspberry Pi, I already had PiLight up and running. Thus, I won’t describe in full how to configure the server. However, there are detailed instructions available on the project page. In short, you will need to do the following:

Make sure that you open the RabbitMQ port (usually 5672) in your firewall so the client can access it.

Setting up the Raspberry Pi – software

The Raspberry Pi is essentially a miniature computer – one that needs an operating system and other software to be installed before it’s useful.

Unfortunately the default Raspbian (debian-based) OS does not include the hardware-based SPI support that we need to send color data to the LEDs. Therefore, we instead use Occidentalis – which is based on Raspbian but does include what we need. Follow the instructions here to go through the steps of formatting the SD card and extracting the OS image to the card. Then, insert the card into the Raspberry Pi, hook up a monitor and USB keyboard, and boot ‘er up!

You should be presented with a simple configuration interface. Here are the steps I went through:

Now you should have a working Occidentalis installation! I choose to run my Pi in a “headless” configuration, meaning that it has no peripherals connected, and I instead work on it via SSH. So, go back to your server computer, and open an SSH connection to your Pi using  (use “ssh” on Linux/OSX, or PuTTY on Windows). Then, we’ll get some software installed and set up. Run the following commands:

Clone pilight-client and set up dependencies:

Copy the settings and configure:

The only thing you should need to change, is to enter your server host name.

That’s it!

Setting up the Raspberry Pi – hardware

The Raspberry Pi should now be ready to go in terms of software – but you still need to connect the lights! So, shut it down and disconnect the power:

Grab your light strings and link them up end-to-end. Look at one of the lights, and try to find an arrow. This arrow points to the output end of the string. We want to connect to the input end. Grab the JST SM connector that fits onto the input end – this is what you’ll wire into the Pi. It doesn’t really matter how you get everything connected (whether you are soldering, or using a breadboard, or some other means), it just matters where everything links up. You should hook things up based on the wire colors that go into your JST SM plug:

It appears that the order of these wires differs between the thin and flat versions of the LEDs – so just go by color. Once you’ve identified the wires, follow these instructions to figure out which pins to hook the Clock/Data lines to. If you run wires from the power plug to the pins on the Pi as per the instructions, then you’ll only need a single power source, rather than needing to power the Pi separately. I definitely recommend doing this.

A little tip if you’re using the breadboard and parallel cable included in the starter kit… Insert the parallel cable into the pin breakout piece included in the kit first (not the Pi) – it will only go into the breakout piece one way. Then it should be obvious which way the cable plugs into the Raspberry Pi.

Putting it all together

Once you’re all wired up, plug the power supply into the socket that you’ve wired in. The Pi should boot up – although the LEDs won’t do anything quite yet. Once the Pi has fully booted, SSH in, and run the following command:

You should see an acknowledgement message that the client is now waiting for data. If you see a connection error, make sure you’ve configured the host name correctly, that RabbitMQ is running on the server, and the RabbitMQ port is opened on your firewall.

Next, make sure PiLight is running on the server – if you haven’t already, run the following commands in separate console windows:

Then, connect to http://<serveraddress>:8000/ and you should be good to go! Just hit Start and the lights should all turn on! Now you can play around, set colors, and add transforms! The lights should update in near real-time.

Final touches

There are a few things you can do to make your installation a little nicer. Here are some ideas for extra things you can do:

7 Responses to “PiLight”

  1. ดูหนังเอ็ก says:

    Today, I went to the beachfront with my children. I found
    a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.”
    She placed the shell to her ear and screamed. There was a hermit crab inside and it pinched
    her ear. She never wants to go back! LoL I know this is entirely off topic but I had to tell someone!

  2. Drew says:

    I’d likе to find օut more? I’d աant to find out more ԁetails.

  3. financialadvisorfan.tumblr.com says:

    This article will assist the internet visitors for setting up new webpage or even a
    weblog from start to end.

  4. alarm Clock says:

    hello!,I love your writing so much! share we keep up a correspondence extra about your post
    on AOL? I need a specialist in this space to resolve my problem.
    May be that is you! Taking a look ahead to look you.

    For an awesome informative review please click the link to this amazing
    site … alarm Clock

  5. connectors in english speaking says:

    connectors in english speaking

    Tom Mitchell » Blog Archive » PiLight

  6. reference says:

    He’s very skilled and wil get my enterprise for aany electrical challenge going forward.

  7. my blog says:

    Neew York Metropolis is without doubt one of the world’s nicfe locations tto live and study and is
    the image oof America.