Why I connected my Coffee Machine to the internet 

And the most odd bug I’ve ever fixed.

Adam Butler
6 min readJul 13, 2014

As a child it wouldn’t be an uncommon sight to see me taking things apart in an attempt to try to understand how things worked, this was usually to my parents disliking as I rarely managed to reconstruct the appliance. I must have broken more than a dozen toys, computers, games consoles or just anything else with movable parts, a motorbike included. I don’t think this is atypical for most developers, our career choices inherit from a fascination with problem solving and the excitement that comes through solving them. I’ve not yet met a developer who would turn down a challenging task over one they feel perfectly comfortable with.

Another interesting observation is that developers are commonly workaholics. Every job has its highs and its lows, sometimes you’re the “Ninja Developer” that shipped twenty awesome new features before lunch and other times you’re maintaining projects day dreaming about if the Infinite monkey theorem would also apply to the job you’re working on that day. These are the days I’m almost certainly hacking away until the early hours of the morning, because like a junkie after a weekend of going cold turkey I need my fix.

The work I do in my spare time is never for profit, and in fact commonly comes at a financial cost to myself, but it’s rewarding, fun and most importantly I get to learn something new. I’ve increasingly found myself working on hardware projects over the last couple of years, it’s new territory for me and I don’t know if it’s just the manifestation of my code in the physical world but there is something extra special about getting something physical to happen rather than just pushing pixels.

The first hardware project I worked on was perhaps the only practical one I’ve ever done. I was working as the only developer for a footwear company, if I was on holiday I’d have to find a machine to log into every Friday and deploy a feature to the homepage. This was co-ordinated with e-mail and social campaigns and often required last minute changes which made it too risky process to automate. So I built a big red shiny button to do deployments. Nothing was easier and it ended up being the process for deployment even if I had a shell running right in front of me… I mean after all who could resist hitting a big red shiny button. The first build worked well but the button went through some practical and far more impractical variations, one such being that it played the one-hit-wonder Friday song by Rebecca Black during deployments.

The next project was after I moved to an agency called Simpleweb. At Christmas we did secret santa where the presents were all bought from local charity shops.

One of the developers got a gum ball machine style M&M dispenser which within a week I had wired up a servo and a RaspberryPi which ran a Node.js application to dispense M&M’s whenever a new feature was completed and merged into the projects `master` branch.

This was a lot of fun, it taught me about Servos, setting up a RaspberryPi, familiarised me with the GitHub API and gave me some playtime to hack away with Node.js. As a bonus at this time I was also learning CoffeeScript, since this wasn’t a critical project it gave me a platform to experiment on without too much concern of breaking anything important.

Following this I built several other hardware based projects — A Kinect powered turret based on my favourite game Portal. — A bird box camera trap and I’m currently working on a Leap Motion powered robot built out of the shell of an old vacuum cleaner. My favourite project however has to be my RESTful power plug.

I’m usually the first in the office and admittedly I’m a grumpy sod until at least my second morning coffee. I wanted to rewire our office coffee machine and build an application that allowed me to start it brewing before I arrived to work. A timer wouldn’t work well as sometimes I’d arrive at 8am whereas other times it wouldn’t be until 9am I needed to devise something smarter. The original plan of rewiring the machine was quickly dismissed as I didn’t want to break the machine, non-caffeinated developers can be mean! Instead I opted to modify a power strip to turn the source power on and off instead, this had the advantage of making it portable and could be repurposed for any occasion.

I started out by stripping down a typical four socket power extender and quickly discovered that I wouldn’t find a easy or more importantly safe way to mount the relays that would control the power supply. I then discovered that you could get plastic boxes that wall sockets screwed into called pattress boxes. A 55mm box provided me plenty of room for a heavy duty four channel relay.

Now, I haven’t yet mentioned short of GCSE level electronics I don’t have any formal electrical training. This was the first time I’ve worked with high-voltages. This wasn’t a problem however plugs and relays are the bread and butter of the electronics, nonetheless I planned, then I planned some more and then I tested my circuit against not one but three schematic tools just to be extra sure I’d wired everything correctly. Furthermore I used certified cables and my relay was rated up to 10A well more than I would be consuming.

I wired plug mostly as normal but instead routed the live via the relay, which is basically a magnetic switch that is controlled by a 5 volt bridge between it and a RaspberryPi. The first test I built allowed me to control the RaspberryPi GPIO pins, and therefor the relay over SSH, it was ready to test. At first I wired up a lamp and it worked first time. To say I was excited was an understatement. I could trigger the lamp on and off from across the room… yes I really was way across the room, with a fire extinguisher to hand just in case.

Shortly after this I built a Node based RESTful interface which not only allows me to turn the sockets on and off but also allows me to run a socket for a specific duration. The beautiful thing about doing this as an API was that it allowed nearly anything to interface with it. Within two hours I could control it with SMS with the help of Twillio, I could use a OS X program called Alfred, I could control it though the web browser and I could trigger it with my Pebble smart watch.

This brings me onto the most interesting, ironic and weird bug I’ve ever had. At Simpleweb we track out application bugs on a system called bugsnag. Any time a site breaks we get notified with an e-mail. We have regular hack nights and for our halloween hacknight I wired the plug to a lamp that was fitted into a pumpkin. Among other implementations, every time bugsnag threw an error the pumpkin would light up and not so spooky sounds would play from it. I forgot about this… at least up until last month.

I’ve had the plug wired to the coffee machine now for a while and it’s been rock solid reliable when I want to trigger it, however sometimes it would mysteriously turn itself on. I just assumed it was rebooting itself occasionally and thought nothing of it more than I should fix that at some point. A couple of weeks back I got an e-mail from Twilio informing me my credit had run out… How I thought, I’ve not used the SMS trigger in months. Looking at the logs I could see lots of messages containing the body message “On” from a US number, who was doing this I thought and why? Upon goggling the number I realised it belonged to IFTTT a service that takes an input, in this case an e-mail from bugsnag and produces an output, again in this case an SMS to Twillio to turn on my plug. So yes, every time a website of ours crashed I was accidentally brewing coffee, but lets call it a feature.

All these projects have been a lot of fun and very interesting, this project though due to it’s RESTful interface gave me an opportunity integrate into lots of different platforms and keep hacking away. Let me know you’re thoughts and ideas in the comments.

--

--

Adam Butler

Full-stack Developer @Simpleweb - Tech Geek - Designer of Beautiful Things™ — http://github.com/adambutlerhttp://lab.io