In case it wasn’t clear from my recent cameo on some RadioShack fliers, I’ve been having a bunch of fun with LittleBits‘, more sophisticated modules recently. A few months ago, I posted a project showing how to use the CloudBit to connect your umbrella stand to the internet. This latest project leverages the LittleBits Arduino Bit, a small linux computer (like a BeagleBone, Raspberry Pi, or UDOO), and the Philips Hue Hub to easily control the state, brightness, and color of your Hue lightbulbs via a tactile interface.
Here’s a quick video showing this project in action:
This project is open source hardware and software. Read on to learn how to make it, and to learn more about how it works!
How it works…
The system architecture of the LittleBits Hue Lighting Controller is pretty simple, but I put a lot of thought into making the system robust, fast, and easy-to-setup. I’ve actually been using this controller daily for the last several months, but I completely rewrote most of the code in preparation for sharing it here – most notably, I built an automated setup routine, added serial device auto-connect logic, and made the system more robust against hardware state changes (like suddenly unplugging the controller from the attached linux computer).
Here’s a diagram that explains how the system is setup:
There are really only three components to the system – the control pad, the linux machine, and the Philips Hue network. When you press buttons or turn the dial on the control pad it sends serial commands to a script that’s running on the linux machine. The script interprets the commands and talks to the Hue hub over the local network to instruct it to change the lights. When you’re setting up the system, you’ll use a automatic setup mode that I’ve included in the Python software. The script handles configuring the linux machine to automatically launch the listening service on boot, it creates the secure connection with the Hue hub, and it allows you to select which lights on your Hue network you’d like to control with the control pad. The Python script also automatically identifies the right serial device and will automatically handle reconnecting the serial interface on USB disconnection events. You don’t have to know anything about configuring Linux serial devices to make this software work – it’s all automatic. It will even work on systems that have multiple USB serial devices attached (even multiple Arduino Leonardo boards – the LittleBits module identifies itself as an Arduino Leonardo).
Ready to make one for yourself? You need to gather materials, get everything assembled, wire it all up, and program the Arduino and the Linux machine. The GitHub ReadMe for this project has all the detailed instructions that you should need. You’ll want to visit the GitHub page directly too, so you can download the source code and 3D designs! The detailed ReadMe instructions are embedded below:
LittleBits Hue Controller
The LittleBits Hue Controller is an easy-to-setup, wall-mountable, physical controller for your Philips Hue lightbulbs. The controller makes it easy to turn the lights on/off, change their brightness, and cycle through preset colors. This is a great project for people who hate having to pull their phone out every time they want to adjust their lights.
What you'll need
- Some LittleBits!
- An always-on Linux Machine. This can be a Raspberry Pi or something similar. These instructions assume a debian-based distro, like Ubuntu or Raspbian.
- A Phillips Hue Hub, and one or more Phillips Hue Bulbs
- Two Micro USB Cables (Right Angle is best)
- A 3D printer (optional, for making the enclosure)
- 4 sets of M3x10 Socket Head Bolts and Nuts (for assembling the enclosure)
3D Print the Enclosure and Assemble the LittleBits
Step 1: Place the Bits on the backer board as shown. Print the button/dial covers. Slightly heat the button/dial covers and press them onto the buttons and covers as shown.
Step 2: Print the enclosure. Place the front of the enclosure on the panel as shown.
Step 3: Press the four M3 nuts into the four slots on the top cover as shown.
Step 4: Place the USB wires into the cutt-out on the rear of the panel as shown.
Step 5: Screw the bolts into the nuts and apply a velcro backer as shown.
Program the Arduino Bit
- Provide Power to the controller, and connect the Arduino cable to your computer (workstation computer, not the linux server computer)
- Use the provided Arduino Sketch to program the Arduino Bit via the Arduino IDE (select Arduino Leonardo from the device menu)
Install the Python Prerequisites
- Log into (locally or via SSH) to the network-connected, always-on linux machine that you'll use (Raspberry Pi is good for this)
- Install Python 2.7 if don't already have it installed:
sudo apt-get install python2.7
- Install Python PIP if you haven't already:
sudo apt-get install python-dev python-pip
- Install the PHue Library:
sudo pip install phue
- Install the PySerial Library:
sudo pip install pyserial
- Install the CronTab Library:
sudo pip install python-crontab
Obtain and Setup the Server Script
- Stay logged into your network linux machine
- Connect your LittleBits Hue Controller to power, and to a USB port on your linux machine
- On your linux machine, navigate to your home directory, and clone this GitHub repo:
git clone https://github.com/sciguy14/LittleBits-Hue-Controller
- Navigate to the server script directory:
- Ensure the script is executable:
chmod 755 LittleBits-Hue-Controller.py
- Execute the script in setup mode and follow the instructions to automatically setup the system:
./LittleBits-Hue-Controller.py -s. The output will look something like this:
- That's it! The handler script will now automatically run in the background at boot. You can launch it immediately to observe its output as you toggle the controller, by running:
./LittleBits-Hue-Controller.py. The screenshot shows the behavior as I adjust brightness, color, and state via the control pad. You can also see it automatically recover when the control pad is unplugged and plugged back in:
Supporting Code and Designs
The LittleBits Hue Controller is released as entirely open source hardware and software. All materials are distributed under the GNU General Public (Open-Source) License. Please Attribute and Share-Alike. All files are hosted on GitHub.