Introduction: JavaStation (Self-Refilling Fully Automatic IoT Coffee Maker)

Picture of JavaStation (Self-Refilling Fully Automatic IoT Coffee Maker)

The goal of this project was to make a fully automatic voice controlled coffee maker which auto-refills itself with water and all you really need to do is replace the patrons and drink your coffee ;)

Step 1: Introduction

Picture of Introduction

As this was my second coffee mod I have learned a lot in the process, particularly that the more complex machine you modify the more problems/bugs you will encounter during the day to day operation. The previous machine was just a simple old 1 switch coffee maker with a relay mod.

The Circolo (full automatic version) is the top of the line premium machine of Dolce Gusto. I had to spend hours on searching for the proper machine because all the other machines from this series using the top mechanical lever to switch between cold and hot water flows as it shown on the picture.

Step 2: Choose the Right Machine

Picture of Choose the Right Machine

My base machine is not just fully automatic but it has remarkable features like turning off automatically after 5 minutes and remembering to the last coffee amount (which will make things a lot easier later on in the modding). The machine's basic operation:

1, Power button pushed

2, Cold water button pushed (it will immediately disperse water to the cup)

3, Hot water button pushed (it will heat up the boiler ~20-60 sec and starts to release hot water to the cup) The power light will be blinking red during the standby period then goes green permanently when the boiler is ready.

This machine also have the ability to detect the following errors:

Water tank is empty

Cup holder is not in place

In both cases the power light will be flickering between red/green.

Step 3: Hardware Modifications

Picture of Hardware Modifications

In this writing I will not detail the disassembly and reassembly of the case because there are videos about it on YouTube. The main microprocessor is hidden right underneath the head panel where the 2 switches are. The boiler is at the right side of the case separated from everything else, the pump and power supply panel is at the left side.

Coffee machine is a heavy duty environment for electronics, none of the side's are perfectly suitable to integrate a circuit to. The right at the boiler has more space but you will deal with heat, obviously the circuit could not touch the boiler plate or be even near it. I have choose the power supply/pump side but here you have to deal with heavy resonance coming from the operation of the membrane pump which can wreck the control circuit / make wires slip out of their connectors over time.

The power supply panel doesn't contain anything useful but can be used to leech off a stable +5V (one more thumbs up for this machine) which can be directly connected to the Arduino's VIN pin bypassing the on board voltage regulator.

Quick hardware list (not full BOM, doesn't include basics):

  1. Dolce Gusto Circulo full automatic version
  2. 5V 4 Channel Relay Module With optocoupler For PIC AVR DSP (I suggest using 4x SIP-1A05 Reed Switch Relay)
  3. Arduino Micro (I suggest using SparkFun Pro Micro or newer in the future)
  4. 2PCS 4n35 FSC Optocouplers Phototransistor
  5. 1/2" Electric Solenoid Valve For Water Air N/C Normally Closed DC 12V
  6. Ultrasonic Module HC-SR04 Distance Measuring Transducer Sensor (buy some extras, you will see later why)
  7. 2pcs Raindrop Humidity Detection Sensor Module Rain Detection for Arduino
  8. 1 Xbee
  9. Pipe fittings for water blocks (can vary depending on ones house, best to buy it in hardware store and put it all together there before buying)

Step 4: Main Connections and the Controller Board

Picture of Main Connections and the Controller Board

The following circuit points needs to be connected:

1, Hot button

2, Cold button

3, Red led

4, Green led

5, Main power on button

6, Shared GND

Unfortunately I have lost my notes/pictures on where to solder these on the board but all can be easily traced back with a multimeter (just use diode test mode to trace the wires back). The soldering was not too hard, pick points with SMD legs and solder the wires there.

The Red/Green LEDs are both located next to each other at the power switch. They are needed to determine machine states (powered on, ready to make coffee (boiler heated up), error). I have take them off directly from the main board, because it's difficult to fiddle around with the small circuit around the power switch.

I was using 4N35's optocouplers to safely interface with the Arduino and read the LED's states. The original idea was to use 5 of them and do both the readings and switch controls as well (make a completely silentl circuit) . Unfortunately this chip could not generate low enough resistance to emulate a button push so I was forced to use relays. I used the generic 4 channel relay module what I had in hand but if I would have to redo this project I would just use small Reed relays (SIP-1A05 Reed Switch Relay with internal flyback diodes) which can be directly connected to the Arduino's output pins (~7mA load) so everything could be put on a 2 level board structure.

The 5 small cables can be easily brought down next to the power cords underneath the supply board.

To use the space more efficiently in the machine I decided to split the electronics to 2 major panels:

The left is the main control board, the right (what I call the communication board) holds the Xbee and although it's not shown on the picture the 2 water sensors (for overflow detection) squeezed behind it. On the top the real time clock (optional for uptime :)) and the 4 channel relay board taking it's place next to the pump at the bottom wrapped into sponge, also gluegunned a bit to protect from the resonation.

For the communication board, I did not bother making PCB just used a regular breadboard because there is not much going on there. It has 6 connections to the main board:

Vcc (5V), GND, Xbee (TX), Xbee (RX), Water sensor1 (Data), Water sensor2 (Data)

Step 5: Water Flow Control and the Refill Mechanism

Picture of Water Flow Control and the Refill Mechanism

I have designed this machine with security in mind, making it impossible for attackers/malfunctions to cause serious water damage to the house since the machine would be hooked up to both the tap and the Internet 24/7. This is what the following 555 protection circuit does on top of the solenoid.

Also note that the solenoid operates from a 12V power supply what I still managed to squeeze into the bottom of the coffee machine next to the pump and relay board. Not to waste power the 4channel relay board switches the 230V main directly to the adapter which will then turn on the solenoid. There is of course couple of microseconds turnoff delay what you have to calculate in for the collapse of the magnetic field both on the solenoid + on the adapter at pulling the plug.

I'm using a standard 3.5mm jack to connect the external water block with a long 3m wire and a small diameter PVC pipe coming out from the block going to the coffee maker.

The top of the water tank is drilled out to accommodate this pipe which then brought down to the bottom of the tank. I would note that it is very important to feed the pipe down to the bottom on the side without going through the middle and interfere with the ultrasonic sensors.

After the solenoid powered on the circuit will automatically shut it off after ~ 4 seconds (which should be more than enough time to fill the tank up to full) and it remains in this state until the next power ON cycle. This circuit is the last line of defense against malfunction and it operates completely standalone from the coffee maker. If the relay in the machine would fail and stay closed the water could flood the house, with this protection it can never happen.

Step 6: Flooding Detection

Picture of Flooding Detection

There are 2 additional water sensors for protection:

  • Sensor1: at the back of the tank for overflow detection from the tank
  • Sensor2: at the bottom of the coffee machine for cup overflow detection

Both of these sensors will trigger an interrupt which shuts the water off immediately, turns on the error light and abort the program execution to prevent an attack like making a million coffees and flooding the house that way. After the program quit the machine will no longer respond to anything and must be manually powercycled.

In case you wonder what would happen if the ultrasonic sensor would get flooded (it happened once :))

It was giving back water level like this for couple of days but even after it dried out it never be accurate again and I had to replace it. The machine was designed to run from the cold tap water so no steaming from hot would damage the sensor. This sensor is only accurate until the water level is 2-3 cms from it.

The elliptic shape of the tank made water level calculations difficult so they were measured and hardcoded into the program to correspond to percentages.

Step 7: Testing and Final Assembly

Picture of Testing and Final Assembly

The machine in it's final state, almost completely hiding the traces of any hacking and if the 3 status indicator LEDs and USB debug port wouldn't be there you couldn't tell that anything else going on inside while it could even house a Wifi connected Quake server :)

When I modify devices I always keep manual usage a top priority. After the hack the machine is completely usable by anyone just as it was, except the water tank cannot be easily removed. Unless you finish the complete water automation part of the design, the machine can only be filled up at this point with a small pipe + funnel combination.

Step 8: Coffee Control Code

Picture of Coffee Control Code

Find the complete Arduino source code attached down below.

Brief explanation of the code:

The main loop calls the xcomm() function, responsible for the command processing, making the coffee, turning on/off the machine.

The code underneath is only reached in case of manual control. It increases a stat counter to keep track how many coffees were made and fills up the water tank automatically but as you notice the refill code is completely commented out for now.

Commands can be sent through the Xbee or over the USB port (Debug has to be enabled at the beginning). When communication comes in from either the orange led blinks for a second to show network activity. The following commands are implemented:

1, CMSTAT – query statistics from the machine

The machine stores statistics about how many hot/cold/manual coffees were made and also get the uptime from the RTC which does not overflow after 3x days so could go up to years :P

2, CMWSTART – starts making coffee and hot drinks with hot water

3, CMCSTART – starts making ice tea and cold drinks with cold water

The hot and cold processes starts with calling the standby() function which does further checks then triggers a power button push. After this the program waits for the green light (when the boiler is heated up) then emulates hot/cold button push. After this it waits 50 seconds (which is more than enough for even the largest cup of coffee) then turns off the power. This wouldn't even be necessary since this excellent machine would turn off automatically 5 minutes after making the coffee but why to waste power? By the way the standby power consumption of the machine even after the modification is less than 2 Watts.

Water refill and security

This machine was designed with security in mind, so it would be impossible for an attacker who gains control to flood the whole house with water. A hardware failure would not result in serious damages either. Next to the hardware sensors there is protections built into the code for the refill. A counter which triggers the ISR routine if the machine is not refilled in x seconds (this for example could happen if the ultrasonic sensor would malfunction and give out 20% after x seconds once the refill is initiated).

There is no authentication, anybody can use the machine within radio range who knows the commands so I have changed the default Xbee piconet ID to something else, also the ERR_INVALIDCMD can be commented out and the machine will ignore any unknown commands.


Double coffee bug: the most annoying thing about this bug is that it started happening couple of months after using the machine with the same code. After the coffe command was issued it made the coffee, turned off and turn on again and continue making 1 more coffee with the same patroon.

I had to start debugging the command duplication from the Android level because I have implemented resending to the code in case of packet loss. It turned out that neither the android, C control software or the Linux kernel on the raspi2 were responsible for this rather the Xbee.

After issuing echo “CMCSTART”>/dev/ttyACM0 on the control node it come out twice to the other end. I concluded that my 2.4Ghz spectrum in my home started to get saturated from the many radio devices in this range which caused an Xbee to invoke some sort of resending in the radio layer and the data was sent twice (not always). Once the first command come in the machines xcomm() function started to process it, however a second one come in right after which was waiting in the Xbees buffer and when the loop finished it started processing the second command. To get around this problem I have introduced 3 thresholds in the code to make it impossible to make more than 1 coffee in 2 minutes. Also there is a limit on the CMSTAT but to not interfere with the C/Android control code it will simply squelch responses for 2 seconds.

The last threshold was put in for the manual coffee counter, because once the machine have reached the ready state (boiler heated up, green light) it have logged the green event hundreds of times bumping up the coffee count.

Step 9: Design Considerations and Final Thoughts

After a lot of trouble from the Xbee communication I would not recommend Xbee for this project. Either use the standard cheap 433Mhz radio with VirtualWire and lowered Bps for stability or embedding a Raspberry PI Zero with Wifi connection directly into the coffee machine.

As the date shows it's an old project so I apologize for small details missing like the connection from the control circuit to the precise pin legs on the motherboard. This project requires a certain level of technical knowledge to do it on your own. If you find any bugs/issues or would like to contribute to this tutorial please let me know.

The control software, methods for voice control is for another part which will make it possible to have your coffee ready by just a voice command before even getting out of the bed.


Swansong (author)2017-10-10

I would love to have one of these in our kitchen!

About This Instructable




Bio: Never stops thinking.
More by NLD:IronForge the NetBSD ToasterJavaStation (Self-Refilling Fully Automatic IoT Coffee Maker)
Add instructable to: