‘Twas the night before Christmas Jumper Day, when all through the house… not a single festive sweater could be found!

Each year in the Citrix office in Cambridge, UK, we take part in the annual Save the Children Christmas Jumper Day. But at 8pm the evening before, I found myself without a suitable Yuletide sweater to wear, so I decided to make my own. Happily, I had some useful bits and pieces sitting on my workbench, so I set about making myself an Alexa-controlled, IoT-equipped, multi-color LED Christmas jumper. Here’s how it works.

The lights themselves are a string of WS2811 red-green-blue, individually controllable LEDs, meaning each LED can be set to a different color under the control of suitable software. I’m a huge fan of these LEDs; they can be easily connected to Raspberry Pis, Arduinos, and many other devices. They can be chained together to form delightfully elaborate displays with very simple wiring; and can produce some really funky colors and effects. In the past, I’ve used them as Christmas tree lights (including using them to scroll dot-matrix messages on the tree!), for jazzing up PowerPoint presentations, for showing load on a cluster of servers, to illuminate a telephone box panel, and more.

A set of WS2811 LEDs, an Arduino Uno and a Raspberry Pi Zero W
In previous projects, I’ve connected these lights either directly to a Raspberry Pi, or to an Arduino, which itself is connect to a Pi via serial-over-USB. The former method is a little hit-and-miss because the 3.3v output from the Pi isn’t always enough to drive the 5v control input to the LEDs, in this case some additional electronics are needed to make it all work. Annoyingly, the particular LEDs I found to use for the Christmas jumper couldn’t handle the 3.3v signal so, to save time soldering an interfacing circuit, I adopted the Arduino method (most Arduinos drive their outputs at 5v). I recycled an Arduino sketch I created some time ago for a big push button that had a circle of 8 WS281x LEDs within its translucent shell, stripped out all the code for the push button, leaving just the part that could take a command over the serial-over-USB channel to change the LED colors (such as “COLOR #FF0000” to show red) — code here.

Pi and Arduino

To make the LEDs internet-connected, I decided to use Azure IoT Hub (we’re doing quite a bit of work with this service at Citrix therefore I’m becoming familiar with it) and so I created a new device configuration in my existing Hub. To communicate with the Arduino and its LEDs, I then created a basic node.js program (code here) to run on a Raspberry Pi Zero W that connects to Azure IoT Hub, from which it receives color commands, and to the USB serial port in order to forward those commands to the Arduino.

With this program set to auto-run when the Pi boots this gave me the ability to send a message from the Azure IoT Hub, such as “red” which the node.js program on the Pi receives over AMQP and translate to “COLOR #400000” and sends to the Arduino via the serial-over-USB connection, with the Arduino then effecting the change on the LEDs themselves. Why “#400000”? Because this whole thing — Pi, Arduino, and LEDs — needed to run on battery power in order to be portable once attached to a sweater; I divided all color values by 4 to dial down the brightness and reduce power consumption.

The next step was to create an Alexa skill to set the LED colors via Azure IoT. Luckily, I already had all the infrastructure in place to do this having built several IoT demos recently. I simply added a new “intent” to my existing (unpublished) Alexa skill to “make my Christmas jumper [color]” — there’s a bunch of supporting stuff to make this work but the important part is that when I make the verbal request to an Echo the Alexa cloud calls my HTTPS endpoint (an Azure Function in this case — code here) telling it that it was the Christmas jumper intent that was invoked, and the color “slot” (i.e. variable) was, e.g. “red”. The Azure Function then calls into the Azure IoT Hub via its APIs to send a “red” message to the device defined above.

Alexa intent:

"slots": [
"name": "color",
"type": "AMAZON.Color"
"intent": "XmasIntent"

Alexa sample utterances:

XmasIntent make my jumper {color}
XmasIntent jumper color {color}
XmasIntent make my Christmas jumper {color}

The result was I can say “Alexa, ask Citrix to make my Christmas jumper red” and within a second or so the LEDs change to the requested color.The final step (for phase 1 – there’s more!) was to attach the LEDs and Arduino to a suitable jumper, put it on, connect the Pi to a USB power pack, and secure the whole thing in my pockets, under my belt, and so on.

So, back to Christmas Jumper Day in the Citrix Cambridge office. My jumper certainly got some attention. For some, the hacky nature of the wiring was the notable piece, but for others the IoT opportunities were more interesting. My fellow IoT geek, Ben Davies, suggested that if I could make the LEDs flash then we could modify the Alexa skill to help find me in a crowd by flashing the LEDs after being asked “Alexa, ask Citrix to find James Bulpin.” Not one to turn down a challenge, I made a few small additions to the Arduino sketch, node.js program on the Pi, Azure Function skill handler, and the Alexa skill itself, to do precisely that. And for good measure, I also integrated it with Citrix’ prototype mapping service to point out my location on a map of the building (stay tuned for more on this and other cool location and context-aware stuff we’re doing).

OK, so this isn’t the most practical solution to finding someone, I’ll admit it, but it did trigger an interesting conversation about what we could do with the same concepts in a more practical scenario. I’m looking forward to the next Citrix Hackathon…