The quest for coffee
Have you ever wanted to wake up with a automatic fresh cup of coffee (or tea) right from the bed every day?
Do you have a capsule-style coffee-maker that now lives on the attic after you figured out the price of the capsules?
Just enjoy reading random articles about coffee-machine hacks?
You find your current coffee maker to be just too convenient, and want your morning routine to be a bit more error prone?
Then you have come to the right place.
Because no-one have ever seen a coffee machine in action before
Youtube mirror in case Lbry/Odysee fails you: Dolce Gusto Melody https://youtu.be/OcXusmTas7Y
How does it work?With a mess of wires, some code hammered into a microcontroller with fingers crossed, and a dash of Home Assistant configuration is how.
image on the right is clickable for zooming, I wouldn’t recommend it though
The microcontroller inside runs a state-machine-like code which allows it to move between the states illustrated below. In essence the user must replace the capsule and move the lever to the red side before it allows brewing. This allows some level of safety, as the machine refuses to run unless it has been manually prepared again after the previous brew.
SVG image, click to zoom. Solid circles are internal states, dashed are external actions.
How could I do this too?
The first thing we do, is to toss out all the electronic circuitry inside except the pump, heater and the levers at the top.
The pump and heater are running on AC/mains input, so we need a relay to switch them. I used a 4 channel relay module here, as that was what I had laying around, but we need no more than 2 channels, this one would work: 2ch 5v relay module.
The microcontroller I used here is a Particle.io Core, but any WiFi microcontroller could be used with some modifications on the code. I only used this as I had bought a couple of them some years ago.
If you are able to read and change the code below yourself then I would recommend some sort of ESP-based controller like: ESP8266 and run https://esphome.io. This would allow you to run without any cloud-integration too, which is a big advantage (as waking up with the internet broken is when you need the coffee the most).
However, if you want to copy-paste the code below, or for some reason need your coffee machine to be available through a cloud, then the Photon kit from the Particle-guys should be compatible.
I used a dodgy 5v supply where the power-connections are way more close to each other than I am comfortable with, hopefully it goes up in flames soon such that I may replace it. I won’t recommend it.
I’ve seen others use the HLK-PM01 before, so get that instead. note, I’ve not tried this supply myself, do not blame me if your coffee (and machine) suddenly gets a bit too hot one morning
There is a thermal fuse installed on top of the heater already, and we can reuse this. If you accidentally blow it (as I did), then it may be replaced by a SF129E. Additionally I added a standard fuse for when the powersupply eventually gives up, here I used a fast-blowing 5a fuse (F5AL 250v). With it I had a cheap glass-fuse holder, similar to this “Glass Tube Fuse Holder”, but I found that this had melted when checking some time later. I guess I recommend using something else.
Bonus: Refillable capsules
To avoid paying Nestlé more than necessary for waking up in the morning, I highly recommend getting some refillable capsules. These may be filled with whatever you’d like, I’ve had success with instant coffee, filter-coffee grounds and tea.
My first attempt on a electronic schematic
SVG image, feel free to zoom
Following is the code I wrote for the Particle Core microcontroller.
Triggering our coffee
Okay, so now we have all these parts and code. How do we trigger it to do anything?
If you are using a Particle.io controller as I did, then you first need to retrieve an access token.
Combining that, and whatever name/ID you’ve given your controller, we can use curl to trigger our machine as follows. With the last command, you should get 10s worth of coffee, which is +/- an espresso worth. Increasing the runtime will of course increase the amount of coffee you get.
# To get the current status of the coffee-maker, replace [DEVICE ID] and [ACCESS TOKEN]. curl -X GET https://api.particle.io/v1/devices/[DEVICE ID]/status?access_token=[ACCESS TOKEN] # Brew 10 seconds worth of coffee, replace [DEVICE ID] and [ACCESS TOKEN]. curl -X POST -H "Accept: application/json, text/html" -H "Content-Type: application/x-www-form-urlencoded" https://api.particle.io/v1/devices/[DEVICE ID]/brew -d access_token=[ACCESS TOKEN] -d arg=10
If we want a more user friendly approach to creating our coffee (and taking the first step into automating it), we can use Home Assistant.
The following configuration block goes into your configuration.yaml file and will provide you with two buttons for brewing coffee, one for a small coffee (20s) and one for a large (35s). You will also get a new sensor showing the current state of the machine. Remember to change all occurrences of
[DEVICE ID] and
.. you now have yourself a overcomplicated coffee maker, that considering Murphy, will likely break the moment you need it the most ;)
Then for the fun part …
We now have all the basic blocks we need for automating this within Home Assistant, and you can easily do this with some basic automation rules. I’ll let this one be a exercise for the reader, as figuring out when you want, and how to trigger your coffee is at least half the fun!
For inspiration, I’ve hooked this together with Tasker on Android such that it automatically schedules and triggers 1 minute after my alarm goes off. If you want to know how, I’ll explain it in details in the next post, this one is already long enough :)
Thank you for sticking around, hope you found some form of use, or entertainment from this! Keeping with the theme, if you want to keep my capsules filled (or if you pity me my capsules and want me to get a real coffee):