Espresso Machine Computerisation


My first post on the forum but I thought it would be worthwhile before I delve too deeply into my project. Some guidance could save me a lot of hours and hassle in the long run.

I have a dual boiler espresso machine that I want to computerise (loosely).

I already have all the parts running with Arduino but I fear I may run into trouble with timing/delays/interrupts when I implement the functions and menu system.

The machine consists of:
2x Boiler Heating Elements
2x Solenoids
1x Water Pump

Very simple.

I've added the following:
2x PT100 RTD's with MAX31865 boards (Measure Temp @ each boiler)
1x HC-SR04 Ultrasonic Sensor (Measure cold water level)
1x Volumetric Flowmeter (Measure flow when brewing coffee)
2x 40A SSR relays (Switching heating elements on/off)
3x 2A SSR relays (2x Solenoids, 1x Water Pump)
2x 1.5" OLED displays
1x Arduino Mega2560

U8G2 using hardware SPI (Driving OLED displays)
Adafruit_MAX31865 (Driving PT100 temp sensors)
PID (Reading 2x PT100's and switching 2x40A SSR's to heating elements)

The Ultrasonic is using digitalWrite , delayMicroseconds, pulseIn for measurements (delay negligible?)

The flowmeter however needs about 500mS delay, possibly less with experimentation.

Brief view of variables I wish to change through menus:

  1. Both PID setpoints
  2. Brew time for Single, Double, Triple shots (essentially should be the same but I want the control individually)
  3. Volumetric based shots should either be 30ml, 60ml, 90ml, but being able to adjust an offset would be nice.
  4. Pre-infusion time/Pre-infusion pressure (based on PWM'ing the Pump)/wait time - again, individual for all brew shot methods and sizes (time/volumetric, single/double/triple)

My big issue I think may be the use of the flowmeter. Would I be able to start a shot, read or reset the Flow Count and be able to automatically stop the shot once the Flow Count reaches a desired value? If so, I want to make sure that this wouldn't allow the PID's to "run-away" as an extraction will be around 25-35 seconds.

I would consider using an Arduino Nano for the Flowmeter to remove the delay and communicate via I2C when pulling a shot using the volumetric methods - Would this be advisable?

Thanks for your help in advance. If any clarification is required I'm happy to provide as soon as I can.

Another question I have is would it be better and/or easier to implement an RTC to track timing for pulling shots rather than use millis()? I wouldn't mind this idea as I could program the machine to come on automatically in the morning.

State machines would be a good fit here. Woluld probably need one state machine per process (i.e. 1 per boiler, 1 for water level, etc.). You’ll need to create a detailed flow chart to break down your requirements, but that’s part of the fun.

Yes, an RTC would be handy, but only for your morning fix. Extaction time can easily be handled with a timer. Do not use delays for anything. They’re absolute death to state machines.

Have fun.

Thanks for your response, glad to hear that it sounds feasible. I'm unfamiliar with state machines but I'll look into it!