I’ve been a fan and user of Octoblu for a while. So, when I saw Chris Matthieu, Octoblu Supremo, tweet a photo of the Octoblu office Christmas tree with a comment of “Who’s up for adding some #IoT to the tree?!” I couldn’t resist the challenge.

I decided, right then, that the Christmas tree in the Citrix office in Cambridge, UK would soon be Internet-connected.

My first step was to find a suitable “thing” to be connected. The criteria included (i) must do something interesting, such as show different colours, and (ii) must be office-safe, so home-hacked mains power was a definite “NO!”

I decided on a cheap, battery powered tree-topper decoration with red, green and blue LEDs with a variety of flashing patterns. I didn’t care about the flashing, really, but the fact that it could told me that the LEDs would probably be wired in a way that I could drive them individually from an Arduino.

Building The StarThe next step was to hack the tree-topper itself. That meant removing the battery unit and the chip that does the flashing, figuring out the wiring of the LEDs (turned out that they were all wired common anode with 6 rings of 5 LEDs with a common cathode per single-colour ring).

My tool of choice for interfacing with LEDs, switches, etc. is the fantastic Arduino family. In this case, I used an Arduino Uno, which happens to have 6 PWM outputs that match nicely to the six LED rings, allowing me to control the brightness of each LED ring individually. A back-of-the-envelope calculation suggested a 150R resistor would give me sufficient brightness, but keep with the Uno’s maximum current sinking limits. I put together a quick bit of firmware for the Arduino which takes commands over the USB serial interface to set the brightness for each LED colour.

Arduino and Raspberry PiNext step was to get this Internet-connected. I decided to use a Raspberry Pi that was already set up with node.js and other bits and pieces for connecting to Octoblu. I adapted an existing node.js script that I’ve been using for controlling a blink(1).

Although there is already a blink(1) plug-in for Gateblu, I prefer to run standalone daemons that talk directly to Meshblu. In this case, I simply replaced the code that sends colour commands to the blink(1) via its library with commands that send colour commands to my Arduino via the serial port.


Putting this all together gave me a Christmas tree decoration that can take colour commands via Meshblu. The final step was to put this into an Octoblu flow so that it did something interesting.

I decided to start with the tree showing the outside temperature (something that might actually make this project a useful tool for my colleagues)! The flow–pictured below–used the scheduler node with a per-minute schedule. This triggers the weather node to look up the current temperature in Cambridge. The output from this goes to a generic function node that has a simple JavaScript function that chooses a colour based on the temperature – colder temperatures being more blue and warmer ones more red. The colour name is sent to my Raspberry Pi and Ardunio via the generic Meshblu device node.

Octoblu Flow

Illuminated tree topperThis worked fine, but the temperature isn’t changing very quickly at the moment, so I decided to force a periodic colour change just to make things a little more interesting. I added another few nodes to the flow to change the colour every few minutes, 30 seconds offset from the main weather flow to ensure that there would be a period of a different colour.

One nice thing about Octoblu is that it’s very quick and easy to change things, so what I make the LEDs do today isn’t necessarily what they have to do tomorrow.

I now have a “software-defined Christmas tree!” Maybe later I’ll change the flow so that the tree shows a colour representing days remaining to Christmas or does some sentiment analysis of Twitter activity …

The IoTree