Software part 1 - the non-coffee bit

A project log for Coffee machine v2

Automatic Slow Coffee Machine | home information device | music player

ronaldRonald 08/11/2016 at 11:260 Comments

The source code of both the software (python) and firmware (atmega, c) can be found on github. It autodetects architecture and can be run on a desktop computer. To make full use of it; an MPD client has to be installed (music), an NS-API token has to be available (train info), and a Dutch postal code + house number combination has to be set (waste collection info). Of course all of this is only neccesary for the home information part, not for making coffee...

The UI will work well enough without all of this. The code has been written to make sure the UI continues to work at most times, catching and mostly ignoring exceptions - because otherwise it's hard to turn the coffee machine off without SSH.

Main, to which koffieui is a symlink, holds everything together. It loads the different modules:

In this log I will explain the first three of these.

System menu

The source code for the system menu resides in This menu is used to turn off the coffee machine, turn off the cd player computer (=music server), and to watch tv.

It shows the state of the cd player computer (aan=on, uit=off) and also shows if music is available. This is done by checking if it's possible to connect to its apache server. There are scripts to mount/unmount the samba share. I might remove this code, since currently I use snapserver/snapclient for in-sync music playing, the coffee machine not having its own mpd server anymore.

The TV, the three Dutch public channels, are streamed from After the first implementation, the token authentication scheme changed. The kind people from helped me out by telling which characters to swap in the token. All the rest I figured out using wireshark. This code is implemented in npo.php, friemelToken(). The code needs changing every once in a while when "they" change their URL or authentication scheme... After getting the stream, it's shown full screen on the coffee machine display using omxplayer.

Hidden in the code is a date/time changer, implemented when I needed to run the coffee machine off network for a while, and I still wanted correct coffee logs. Sadly, it stopped working at some point, probably because of permissions. Currently I don't need it, but the code is still there. Feel free to use it for implementing your own UI.

On the display, the next waste collection type (paper / green / plastic) is shown using an icon of the container and a number for the day count until waste collection. The web site scraping code I developed is in

The display looks like this:

Train timetable

Because I used to live very close to a train station, I liked the train time table on the machine, in exact the same way as displayed on the real displays. I used Python-API for fetching the information, and built up the display in

It looks like this:

Music player

Finally the coffee machine is the kitchen's music player. A python fronted was written using python-mpd. All code is in It looks like this:

The progress bars used in this UI and the coffee UI are in, a progress bar library written to make easy progress bars in different colors.

Hardware abstraction layer

The hardware (buttons, temperature 'display', light, counter, and all the brewing hardware and sensors) is abstracted away in The pigpio library is used to access the GPIO's to which the buttons are connected. Additionally, python-smbus allows for accessing the Atmega.

To be able to test everything on a desktop, a simulation is provided in It is automatically selected based on the architecture.