Monitor button press on coffee machine

Hi everyone,

I hope somebody can help me with my project. I think the solution can't be very hard, but I am not able to put it together.

What I want to achieve is to connect an Arduino to my coffee machine (DeLonghi ECAM 22.110B), in order to track the amount of coffee I consumed. Later on I would like to log and send the data via Blynk app to my smartphone. But currently I am stuck at retrieving the data.

To track the coffee consumption, I think the easiest way would be to just register the button press on the coffee machine.

I build a dummy-circuit with a button on a breadboard and registered the button press there via the digital input, following this tutorial. I also measured the voltage between the legs of the button, which is 0V when pressed and 2,5V when released.

But when I try to transfer this logic to the coffee-machines PCB, I don't get any signal. Just a floating value, which also doesn't change when the button is pressed. I connected the D2 pin to one leg of the coffee-machine. I think GND and 5V are coming from the machine to the button. I also tried using the INPUT_PULLUP command, but no difference.

Next, I tried reading the signal with the analog input. I connected the A2 pin to one side of the button on the machine and the other side of the button to GND. Now I can somewhat register if the button is pressed, but the signal is fluctuating between 0 and 400 when not pressed and 10-15 when pressed.

I think I am missing something obvious, probably the wiring from my arduino to the coffee-machine is wrong. But I don't want to try too much out on the coffee-machine, because I am afraid to break it.

I would be very thankful for any advice on this topic! I attached some pictures, hope these help.




Best regards :slight_smile:

You have to connect the ground of the Arduino to the ground of your coffee machine as well as the signal from the push button, the one that is not ground.

Take your volt meter and measure the voltage across your switch, that is from one pin to the pin diagonally opposite. If you read a positive, then your meter's leads are correct, that is the black lead is the ground. However if you read a negative voltage then it is the red lead that is the ground.

If the voltage you read is anything above 5V then you will have to use an optical coupler to get the signal into an Arduino.

That's not the correct voltage. It should be 5V, not 2.5V. Try the tutorial again. If you don't get 5V, post an image of your breadboard circuit.

There is no point risking damage to the coffee machine until you can get that tutorial working correctly.

What makes you think that?

You may already have damaged it because you have so little experience of basic electronics and no experience of reverse-engineering commercially produced PCBs.

Don't attach the Arduino or anything else to the machine's PCB until you have discovered a little more. Touch it only with the probes of your multimeter.

First thing is to establish what is ground. There's an easy way to do that. The two chips you see are commonly available, so you can look up their pinouts to find out which pin is ground. For example, one of them is a 74hc4051:
download (2)

Can you see the circular spot on the chip? That indicates pin #1 of the chip. Using the pinout diagram above, you can see that the chip's ground pin is on the same side as the spot but at the opposite end of the chip. It's pin #8.

Now you know a pin on the PCB which is ground, you can use that to figure out the voltages on the pins of the buttons. Connect your multimeter's black probe to the ground pin on the chip and use the red probe to check the voltage on each of the 4 pins of the button, when it is pressed and not pressed.

Hello
You can decouple electricaly both systems by using optocouplers simply.

Thanks everyone for taking the time to explain this!
You are right, that Idon't have much experience in reverse engineering. But I would love to learn more about it. If you can recommend any good tutorials, blogs etc., I would be very thankful! :slight_smile:

So I measured the pins of the button, as you described. Both pins on the left side measure 2,7V, the ones on the right 0V.

If I understand @Grumpy_Mike correctly, the next step would be to connect the GND of the Arduino to one of the grounds of the Button, and the digital input pin to the other ground?

In the meantime, I will read a bit about optocouplers :slight_smile:

It looks like the voltage of your coffee machine is being powered by 2.5 volts. Check this by measuring the pin 16 on that chip.
If that is indeed 2.5V then use the analogue pin.

However that chip is an analogue multiplexer so it is more than likely that those switches are part of a scanning matrix, so you will not get a constant signal from a button press, it will be a pulsed signal and your meter is only giving you a smaller value because it is not constant.

The thing about reverse engineering is that you have to know how to design circuits in the first place. That is the configuration that circuits can take. You also need an oscilloscope so you can see the signals in what you are trying to interface to are actually seeing what you expect.

Thanks for your help!
I measured from GND to Pin 16 on the chip and got ~5V.

How do I proceed with this info? Connecting the analogue input of the arduino with the 2,5V side of the button and the GND of the arduino with the ground side of the button?
Is it realistic to measure this pulsed signal with the arduino reliably?

Or is there a better approach, to read the button state? I.e. monitoring the button press with a vibration sensor or something like this?

I also read into optocouplers, but can't figure out what their purpose would be, because the buttons are working with a voltage, the arduino is capable of.

Possibly not with an analog pin.

You could try connecting it to a digital pin and use pulseIn() to see if you are getting some kind of square wave signal. Ideally you would use an oscilloscope at this point. Can you get access to one, and someone who knows how to use it?

Yes, you don't want to measure the exact degree of pulsing you just need to register that it is. So using the analogue read function it will return something other that the 1023 that you would with nothing pressed. In order to do this you have to enable the internal pull up resistor to the analogue input pin you use.

In this case yes, but hacking like this can be a two way street, the load on a pin might give a problem for your machine. Especially if the pull up resistor on the analogue input effects the normal reading of the pin.

Okay, so would this code work, if I connect the Arduino GND to one of the ground pins of the button and the A0 pin to one of the +2,5V pins of the button?

int val = 0; 

void setup() {
  Serial.begin(9600);
    pinMode(A0, INPUT_PULLUP);

}

void loop() {
  val = analogRead(A0);
  Serial.println(val);
}

@PaulRB Could be possible to find somebody. If I understand the oscilloscope correctly, it would help me understand the pulse of the signal, right? How would I then proceed to capture this/ convert it into a signal for the arduino to measure if the button was pressed?

It stands a chance so try it and see.

I think you misunderstood what was meant. The oscilloscope tells you exactly what is happening, depending on what you see then you can make decisions on what you need to do, if anything, to process the signal.

So I tried it out, this is what I got:
When pressing the button, the analogue input pulses between 998 and 1014, when released between 13 and 15. Is this useable?

Can I monitor this signal with an if-statement to categorize the button into pressed or released? Or is there any reason to not do it this way/ a better way to do it? :slight_smile:

Yes I would think so, give it a try.

Tried it and it works :heart_eyes:

So do you think I would be fine, if I solder a wire to each leg of the button in order to build a more permanent solution? Or can you recommend a less invasive option?

btw thanks a lot for your and @PaulRB help, really stoked to get this working (even if it's not a very challenging problem :smiley: )

No, anything short of soldering would be unreliable. I would not use those wires with plugs on them. Use normal wires and make the soldered ends as short as you can, maybe even half the length you thought you should use. Just make sure the coffee machine still works before you put it all together.

Alright!
One last question: I measured all buttons now. Every button has this combo of one side 2,5V and the other 0V. But there is one button, which has 2,5V and 1,1V.
Can I attach the arduino in the same way as with the others. So analog input on 2,5V and GND to 1,1V?

Might it be simpler to construct a coffee-cup-size Arduino-connected weigh scale and record actual ounces produced?  Set the cup on the machine equipped with the scale, let it stabilize and make your coffee.  No fussing with the internals of the coffee maker (fire/shock hazard).  Add a real time clock and generate statistics.

Your idea doesn't sound too bad, definitely simpler. I might consider this, if I run into too many issues :smiley:
For now I soldered wires to one button and will try to get it running with the arduino, maybe scaling it up later on if it works.

By side do you really mean one corner and the other?

But as long as you can distinguish one button from the other it should work.
It is not unusual that one button could be different because the matrix would not be scanning all the time.