The espresso maker that knows when you want a shot (see video credit below)

Are you ready for the next killer application? Google, Twitter, Facebook, and Apple spend million of dollars a year to do it better. While I’m sure it will make us more efficient, will it make us happier? This blog attempts to show one way artificial intelligence and machine learning (AI/ML) can make you happy by using a Raspberry Pi to hack a semi-automatic espresso maker that knows when you need a shot and warms up the machine beforehand automatically. No longer will you need to turn on the machine when you wake up or for your afternoon espresso drink. This machine learns your patterns and does it for you and much more. In this post, I will explain this totally useful modification of a semi-automatic espresso maker that may just make it the most important machine in your day.

Key Upgrades to the Rancilio Silvia Espresso Maker

A self-grading machine learning algorithm turns on the machine when you need an espresso

The boiler temperature is controlled to within 1 degree Fahrenheit with a PID type control

An auto-shot mode turns brew pump on only when the temperature is ready

A web application controls and monitors the machine from anywhere

The water tank level is displayed with a bar graph Nixie tube that doubles as a shot level and temperature display

The Raspberry Pi zero is mounted in a custom 3D printed case and located next to the water pump

The 3D printed case shrinks the electronics into a compact assembly

The same classic Rancilio Silva Look – just better and easier to use with nothing permanently modified

I just may have worked too long on this mod, as the artificial intelligence part is just the start. Not only does the machine learn when you are going to take a shot and warms up thirty minutes beforehand to prepare you for the perfect shot, the hack also has the features to help you make the espresso better than any coffee shop. With a PID type control, it precisely controls the temperature of the boiler within just 1 degree, monitors the water tank and adds a volumetric shot dispenser . It also has a embedded web application allowing you to monitor and control the machine from anywhere and the web page works nicely with a smartphone. The water tank is displayed with a retro Nixie bar graph display that also doubles as an intuitive multi-use timer and temperature display. If you are not using the machine, it automatically shuts down to save power and improve the lifetime of your machine. If it needs to warm up, it reports to you the seconds before it will be ready to dispense a shot so you are not wondering and waiting. You can literally put you espresso cup under the brew head and press the espresso button. If the machine is not ready to pull the shot, it will let you know and prepare itself by either heating up or cooling down. You can then walk away and it will pull the shot when it is ready. The added volumetric water sensor will turn off the shot after a given amount of volume.

The semi-automatic espresso maker hacked in this blog is the robust and sturdy Rancilio Silvia, but the technique can be modified to other similar brands and models. The Rancilio Silvia is sturdy and robust, but super simple with just four buttons and a steam valve and provides a perfect platform to add today’s AI/ML technology, making them easier to create that perfect espresso shot. The great looking Rancilio Silvia was only upgraded and nothing was permanently modified, ensuring the initial investment was not at risk, only enhanced. Are you ready to make your own espresso maker that knows when you want one? The description of the modification, the schematics, layout, 3D enclosure, and source code are described below and available for download as an open source hardware and software project.

Who Cares about preheating your espresso maker?

By looking at your past history, this espresso maker will estimate and turn on the machine thirty minutes before your next shot, learning your patterns and providing the optimum heat for your next shot of espresso. The water in any single boiler espresso maker will be at the correct temperature in about 3-5 minutes, but the optimum espresso shot can occur after the machine has warmed for at least 30 minutes. The reason for this is simple thermodynamics. The best espresso is made by keeping the temperature of the water at a constant known temp for the entire shot as you push the water through the ground coffee, the port-a-filter, and then into your espresso cup. A cool machine will dramatically drop the water temperature as it travels from the boiler into the espresso cup, changing the espresso taste and considered by many to be sub-optimum. A fully warmed machine and port-a-filter will ensure that as cool water is pumped into to boiler to push water out the port-a-filter, the thermal mass of the machine maintains the temperature as much as possible. This project sets up your sturdy, but basic single boiler system to provide great shots at all the times you need by learning your behavior.

Energy save mode saves money and increases machine lifetime

A smart machine means you can save energy by turning off the heater when no espresso shot is needed or expected. The other benefit is that you will also save the lifetime of the machine. I don’t know how may times I left my machine on when I was done with my morning espresso. This machines does it for you. Even after you take an unplanned shot, the energy save mode will turn it off if there is no activity for one hour. In the case the machine has not been used for a day or a programmable amount of hours, It assumes you are on a trip and stays off until the next button is pressed, further saving energy until you return.

Time series analysis for machine learning

Looking at past history to forecast when to heat up machine. This is an example of a heavy user

By using past patterns, a time series analysis sets a forecast model for future events. In this case, the event is your need to take an espresso shot! The model looks at your last six weeks of shot history and assumes a 7 day series. It then grades each sixty minute segment during a week and if the total forecast is over a threshold, it will designate that period to heat up. If you take an espresso shot within one hour of this time, it then designates this a successful forecast. The algorithm then tallies the percentage of the time it has been successful.

Precision thermocouple temp control

Where to put the Thermocouple
The type K thermocouple is mounted under the original but disconnected thermostat

The most popular hot rod item for Rancilio Silvia machines is the venerable PID temperature control. This machines takes it a step further and combines PID with bang-bang control using a type K thermocouple for the fastest temperature response and heat up possible. The Rancilio Silvia comes with a stock thermostat sensor that has literally 40 degrees Fahrenheit of variation over a turn on and turn off thermostat cycle. The temp sensor circuit uses the easy to use MCP9600 thermocouple sensor IC that does all the hard work of calculating the type K thermocouple temperatures and is read by the Raspberry Pi over I2C.

Accurate water level sensor for flow control

I was always forgetting to check the water when running the machine, but now a water sensor never allows me to mess up and provides a flow control to dispense a programmable shot amount. The water sensor is made with an accurate inductive position sensor using the LX3302AQPW sensor IC that measures the water position and allows the shot to be stopped automatically when the shot is complete. Inductive position sensors are magnetic field sensors that don’t use a magnet. Instead, they can precisely detect the position of a metal target. In this case, the metal is attached to a water float and by accurately measuring the water level the precise amount of water can be dispersed into the shot glass. The software can be programmed for a single or double espresso and also has a max shot time parameter. The LX3302AQPW communicates with the Raspberry Pi over a robust SENT protocol for accurate digital communication. A previous blog shows the details of how this is implemented.

A web application makes everyone a better barista

The web application controls and monitors the machine from any browser. It displays the current status and has a help mode that instructs the barista what is going on and when to expect a change. It will display the time until the machine is ready for an espresso, so you don’t need to wonder or wait aimlessly. The temperature is graphed and the last five shot times are displayed along with an average to help dial in the perfect espresso shot. The water level is also graphed. The Brew, Schedule, and Data pages allow you to adjust brew and steam temperatures, fine tune the machine specifics, and display your espresso data.

Smart auto-shot switch ensures the right temp, even for novices

When you are ready for an espresso shot the auto-shot control ensures it will always be perfect. When the espresso shot switch is turned on, the Raspberry pi control will ensure the heater is at the right temperature before starting the pump and will give the user feedback via the Nixie display and the web application. If the temperature is too low or too hot, the nixie display will flash five times indicating an error and provide a display showing the boiler temperature status and time required for the shot will be ready. There is no need to stay at the machine as the machine will do this all automatically, you can walk away and the espresso shot will start once the correct temp is reached. If you want the precise amount of time required before it is ready, the web application web page lets you know the wait time.

A bar graph Nixie tube gives intuitive machine feedback

The Nixie tube display adds a bit of retro look to the machine, but also provides machine feedback so you don’t always have to refer to the web application when you need a shot. Its main function is to display the level of the water tank, but it also gives a feedback of the shot volume and the machine temperature when a shot is not ready or steam is wanted.

3D printed case houses the Raspberry Pi and peripherals

The 3D case was designed to house all the electronics and fit inside the Rancilio Silvia without any modifications. The Assembly holds the Raspberry Pi zero, the Nixie tube hat described in a previous blog, the Nixie tube power supply also described in a previous blog, two temperatures sensors, two solid state switches, and two switch state sensors. The solid state switches are directly mounted to a heatsink, ensuring they can handle the heater and pump currents. This heatsink can also be mounted to the bottom of the machine for even higher current capabilities, but I did not find it was needed. The case has slots for all the connections to the machine for the 2.5amp USB power supply, high voltage AC wires for the brew pump and heater, high voltage AC wires to sense the espresso and steam buttons, the boiler mounted thermocouple, the Nixie tube display wires, the water sensor, and a slot to allow the SD card to be replaced without opening up the case. In the pictures below, the wiring of the machine case and machine are shown. The wires in the images have a lot of extension to allow easy debug during development. Shortening them and replacing the wire nuts with solder to make it more robust.

The mount location of the 3D case ensures the coolest location in the machine, protected and isolated from the water tank, and also does not block the Raspberry pi zero’s WiFi signal.

Putting it all together

The raspberry pi zero is the brains that controls the machine and operation without the use of another microcontroller. The position sensor is attached via GPIO controlled SENT bus. The temperature sensors are attached with the Raspberry Pi I2C bus. The Nixie display uses the raspberry pi’s PWM bus. The web application is hosted directly on the raspberry Pi using a Flask framework and the control program was written in Python . The list below provides links to the design files, software, and 3D designs. For access to all of the content, please subscribe. It is Free!

All links below are now updated along with water sensor with the published Blog: A Water Tank Sessor for the Rancilio Silvia Espresso Machine

  1. Espresso Connect Web Application Source Code Files :Free Subscription Needed
  2. Espresso Connect Hardware and 3D case Design Files :Free Subscription Needed
    1. Espresso Connect PCB at OSH Park(TM)
    2. Water Tank Sensor PCB at OSH Park(TM)
    3. Project Parts List Only
  3. Raspberry Pi Hat Nixie Bar Graph Driver
  4. Nixie Power Supply

Please let me know your thoughts

I hope you enjoyed this blog of an espresso maker that knows when you want an espresso shot. Let me know your questions and comments below. This is just the start of the series on modifying and hacking coffee and espresso makers. Subscribe to dig into the design files above and you can be notified when future blogs are published. On future blogs, we will dig into the individual parts of the modifications, describing the sensors, the PID control, the solid state switches and the web application so you can apply them to your designs. Is there a feature missing you would like to see?

Surfs Up!

Credits