« Back to all articles

Coffee with Pi

Written by Devhouse Spindle on 15th October 2015

The Raspberry Pi

About a year ago I bought myself a Raspberry Pi to start experimenting. The Pi can both be much fun and useful. Here at Devhouse Spindle there are Pi’s connected to tv’s, they’re used for monitoring servers and show what we are working on. The Pi has a GPIO port which can be used to control and monitor electronic signals from other devices. My Pi was only used for a simple Linux server to teach myself some scripting, when I decided it was time for a project.

The goal

My main goal was to make my coffee machine brew a cup of coffee initiated from my smartphone. When you make a cup of coffee you normally have to wait for the machine to warm up, grind beans and finally brew a cup. Controlling it from your smartphone makes it possible to start this process earlier.


Beside a Raspberry Pi, a coffee machine and an alternative way to brew coffee during this project I needed:

  • 2 Jumper wires (female to female)
  • 1 Relay (normally open)
  • 4 Pieces of cable to solder on to the coffee machine
  • 1 Old USB power supply (providing 5V 1A)


The control buttons on the coffee machine are normally soldered on a PCB and from there the signals are transferred to the mainboard. I decided to solder two pieces of cable directly on the switch to connect the PI to the coffee machine. These cables are connected to ports 30 and 87 on a relay (see figures ). When the relay is energized it simulates a press of the button.


The Raspberry Pi powers the relay from its GPIO ports. The GPIO ports can be controlled from a bash shell. A tiny bash script will energize the relay.

#! /bin/bash

gpio mode 11 out
gpio write 11 0
sleep 1
gpio write 11 1

Connecting the Raspberry Pi

The Raspberry Pi fits perfectly in my coffee machine and is powered by an adapter connected to the power source in the coffee machine. I installed a WiFi module so there is no need for an ethernet cable.


Controlling from a smartphone

To execute this bash script from a smartphone, I made a small webapp and hosted it on my NAS server. I could of course host this on the Raspberry Pi, but my NAS server loads the webapp faster because it’s connected by cable.

The webapp is written in HTML, JavaScript and PHP. HTML/CSS is used to create the interface. A little JavaScript generates an Ajax call and a PHP library is used to setup an SSH connection to the Raspberry Pi. The PHP script will check the client’s IP and compares it to check if the device is connected to my local WiFi network and the owner is allowed to drink coffee.

image00 coffee image03 coffee

The best wake up call ever

And there it is, with one tap in the app you’ve got great coffee that is ready the moment you step out of your bed. Standing up was never this easy!


Your thoughts

  • Written by Harold on 20th October 2015

    But… who puts the cup under the machine?

  • Written by Gijs Brandsma on 4th November 2015

    I would like to find a cool way to automate that. In the mean time you will be reminded to replace your cup with a new one while ordering.

Devhouse Spindle