The amazing MQTT-enabled ducks!

This is a guest post by Hursley’s Chris Phillips (aka @cminion on Twitter). Take it away, Chris… and you’ll find more from him on his blog.


Many eightbar readers may have received one of those gadget catalogues you get through the door, with weird and wonderful widgets to ostensibly help with everyday life. “How have I ever coped without a Wifi Fondue set?” and similar thoughts may have run your mind. However, one thing these catalogues aim to promise is the integration of technology into everyday life; the dream that if technology is pervasive enough, it could remove all those little annoyances that we experience: forgetting a recipe, not knowing when our friends are turning up at the pub, having to get up twice to make a cup of tea, and so on… missing a phone call, because the phone is not loud enough, or set to vibrate, or other such vagaries of the modern telecommunications device. If only one could make a normally unobtrusive device that would alert one to a phone call, or a doorbell, or a new email, in fact pretty much anything!

Back in January I made some MQTT ducks. The aim was to make them flash on or off when receiving signals from my Ubuntu server.

Now, you may wonder why I would want 20 rubber ducks to flash when my phone goes off. Well, this was about the same time as I decided I wanted to make a unobtrusive alerting device. There is no scientific or technical reason in itself. I just had a Mini Cooper’s worth of rubber ducks sitting around, unemployed. Therefore I designed a simple project to get to grips with the world of Arduinos not only educating me but also putting the lazy mallards to use. I found some cheap fairylights just before Christmas and had the aforementioned large supply of rubber ducks (as you do).


  • 1 x Freeduino
  • 1 x 20 LED Fairy lights (£3)
  • 1 x USB Printer Cable (via
  • 20 x Rubber Ducks



  • GlueGun (£1.50 from Woolworths during the closing down sale)
  • Scissors

The construction was very simple. Making a small hole in the bottom of each duck, I inserted an LED and glue gunned it into place. I checked the effect with the batteries to see the result.


Removing the battery component with a pair of scissors and stripping the wire coating revealed the multi-core ends. These were plugged into the digital pin thirteen and the digital ground on the Arduino. To confirm the wires were plugged into the correct pin I pressed the reset button. The ducks and LED thirteen on the Arduino would then quickly flash.


Coding for Arduinos is very basic. The program I wrote received a 1 or a 0 down the USB cable. When it received a 1 (49 in ASCII) it turned the ducks on. When it received a 0 (48 in ASCII) it turned them off.

int LEDPin  = 13;
int inByte =0;

void setup() {
void loop(){
    if (Serial.available() > 0) {
      inByte =;
    if (inByte == 49 ) {
    if (inByte == 48 ) {

To connect this to my Really Small Message Broker using MQTT, I modified an excellent & simple Perl script written by Andy Stanford-Clark. His script reads RSMB topics for specific entries. I created a listener that watched for messages being passed on to the Ducks/ topic. If the content of the message was on it sent 1 down the wire to the Arduino, and if it received off it sent 0.

Next move… well someone at Pachube put forward the idea on Twitter of controlling with their infrastructure. Now, I can send an on or off message to a Pachube feed using Twitter. My server at home then checks this feed every 15 seconds for any changes and sends a message to my RSMB as required.

Thanks to the guys from for providing their leftover ducks and for providing the USB cable!

Mad scientists?

IMG_3669 4.JPG IMG_3670 4.JPG

Just an average day in the Hursley tea bar!

Martin Dix from CurrentCost visited to deliver a bunch of meters for people who had attended Home Camp 08. Whilst he was with us, Andy Stanford-Clark hooked up a (battery-powered) meter to one of his mousetraps to show how it is possible to detect traps going off using the meter – this is the same technique he uses in his automated home system. He also showed the same message arriving in his MQTT broker on his Ubuntu laptop. The table was soon awash with gadgets, wires and tools. I brought along a camera or two, Dale brought along some questions about the software internals of the new devices, and a great time was had by a bunch of geeks over tea…

No mice were harmed during this meetup, but a few wooden coffee stirrers were put through their paces in some vicious mousetraps.