joejoinerr
Posts: 5
Joined: Sun Jan 04, 2015 7:59 pm

Controlling a coffee maker with Raspberry Pi

Sun Jan 04, 2015 9:04 pm

I recently had to buy a new coffee machine since I broke the jug and couldn't find a replacement, so I purchased one identical so I could use the same jug for two and decided I would to connect the Pi's GPIO into the circuitry of the original machine so that I could control it over WiFi.

I've done the scripting part just fine since I'm fairly familiar with Python and APIs, but I have no electronics knowledge whatsoever. The machine is controlled by either a button or a timer with an LCD, all on the master PCB which I have attached a photo of.

Is it possible to tell looking at the board which pins of the GPIO I would need to connect to which of the four cables from the circuit board because I can't figure it out? The ON button I assume I need to control is the far left of the back of the PCB (or far right of the front).
Attachments
IMG_20150104_193341.jpg
PCB Back
IMG_20150104_193341.jpg (61.36 KiB) Viewed 7029 times
IMG_20150104_193440.jpg
PCB Front
IMG_20150104_193440.jpg (61.31 KiB) Viewed 7029 times
Last edited by joejoinerr on Mon Jan 05, 2015 5:18 pm, edited 1 time in total.

Gaijinsan
Posts: 6
Joined: Thu May 24, 2012 10:48 am

Re: Controlling a coffee maker with Raspberry Pi

Mon Jan 05, 2015 4:21 pm

Looking at the PCB. It seems that the on switch is activated by pulling the pin on the chip to ground. The best advice is to use a relay between the pi and the button.
The gpio will trigger the relay. This will complete the circuit on the button side which will switch on the coffee machine.

Gaijinsan
Posts: 6
Joined: Thu May 24, 2012 10:48 am

Re: Controlling a coffee maker with Raspberry Pi

Mon Jan 05, 2015 4:29 pm

Looking at the connector you were asking about. On the pcb side my guess is that the top one is power (probably 5v) the second one down is ground. The next two pins are likely to be sensors for the machine so that it knows when the coffee is ready.

jfklingler
Posts: 1
Joined: Mon Jan 05, 2015 4:21 pm

Re: Controlling a coffee maker with Raspberry Pi

Mon Jan 05, 2015 4:53 pm

You'll need to get out your multi-meter to check a few things. The maker will need to be powered from the mains, so be careful how things are laid out and what you touch when it's hot (no pun intended). I'm going to make a bold assumption that the controller on the back operates on direct current (DC). The inputs on the controller on that circuit board are either active-high or active-low (whether the pushing the button connects the input to V+ or ground, respectively); it smells like active-low, but you need to figure it out for sure. On the back of the board, you'll notice that all of the buttons share a common connection. Pressing the button connects the corresponding pins on the top, which are connected to inputs on the controller, with the common connection on the bottom. At the far left of the back of the board is the four-pin connector. The top two pins connect to traces that follow a parallel path and there's a capacitor (mounted on the front of the board) across these traces, so I'm going to guess that these are your ground and V+ lines. With the power on (be careful), measure the DC voltage across these. Depending on which meter lead you touch to which line, this should tell you which line is ground and which is V+. You'll also need to know what the actual V+ voltage is. You will mostly likely fry your RPi if you try to source or sink anything but 3v3 on the GPIO. We can deal with the difference, but we need to know if it's there. (Another response recommends using a relay - this is a good idea as it will electrically separate the RPi from the coffee maker.) Let us know what you find.

orukusaki
Posts: 1
Joined: Mon Jan 05, 2015 4:56 pm

Re: Controlling a coffee maker with Raspberry Pi

Mon Jan 05, 2015 5:04 pm

There's no way this circuit switches 240v for the coffee maker, so there'll be a relay somewhere else, connected to one of the lower two of those pins (the other is probably for a thermal sensor). Hard to tell which though.

As Gaijinsan says though, if you wanna hit the switch with the Pi, then you really just need to pull the IC Pin connected to that button to ground. I'd probably start by soldering a wire to that unused pin on the button.

User avatar
rpdom
Posts: 15583
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Controlling a coffee maker with Raspberry Pi

Mon Jan 05, 2015 5:09 pm

I'd use an opto-isolator instead of a relay. The current is going to be tiny and the opto can be driven directly from a GPIO via a suitable resistor. You just have to make sure you get the output side the right way round across the switch - trial and error should work without damaging anything.

joejoinerr
Posts: 5
Joined: Sun Jan 04, 2015 7:59 pm

Re: Controlling a coffee maker with Raspberry Pi

Mon Jan 05, 2015 5:22 pm

rpdom wrote:I'd use an opto-isolator instead of a relay.
This was suggested on Twitter but then I was advised against it due to my lack of experience. I am beginning to understand relays now so I think I'll be purchasing one of those.

joejoinerr
Posts: 5
Joined: Sun Jan 04, 2015 7:59 pm

Re: Controlling a coffee maker with Raspberry Pi

Mon Jan 05, 2015 5:35 pm

Gaijinsan wrote:Looking at the PCB. It seems that the on switch is activated by pulling the pin on the chip to ground. The best advice is to use a relay between the pi and the button.
So...
  • GPIO pin to the first (top) wire?
  • Ground pin to the second wire?
Have I got that right? So then turning on the GPIO will turn on the machine?

Stoomtronic
Posts: 5
Joined: Mon Jan 05, 2015 5:18 pm
Location: Netherlands

Re: Controlling a coffee maker with Raspberry Pi

Mon Jan 05, 2015 6:51 pm

I would like to make some remarks about electrical safety here, especially usefull for the eager but unexperienced makers and hobbyists.

Mains is supplied to our houses by a large transformer (in the US often a so-called pole-transformer) in your neighberhood that is converting several kilovolts of power (typically 10kV here in the Netherlands) to what high-voltage engineers call "low voltage", somewhere in the range 100-250 volts depending on the country you live in.

For reasons not important here one of the secondary winding connections is connected to earth, the other is called "Live" and both are brought to your doorstep to make living comfortable. As a result one does not need to touch BOTH wires to experience discomfort (as some of us perhaps already have discovered) or worse. Touching the live wire while being connected to earth (by e.g. your feet on the ground) can cause current to flow and harm to be done. A mains powered device is therefore often enclosed in isolating material to stop us from touching live parts, and since mains plugs do not always pay attention to polarity (as they do in the UK) ANY conducting part of an appliance may be live, and that includes electronic parts on a PCB.

For mains powered devices that require metal parts that may be touched (e.g. phone chargers etc.) some solution is obviously required and the usual solution is a transformer. In a transformer the electrical energy from mains is converted to a magnetic field and back again, and by providing sufficient isolation material between the (mains connected) primary winding and the secondary winding no unsafe situations can occur anymore by touching any part of the secondary circuit (This is called galvanically isolated). Another important purpose of this transformer is to reduce the voltage to a level electronics (or e.g. low voltage halogen bulbs) are comfortable with and if this is a safe voltage level (below some 40V) it is also safe to touch all parts of the secondary circuit at the same time.

Transformers providing this isolation would add cost and that is why they are usually not present in mass-produced consumer goods since low voltage power for the electronics can be provided at significant lower cost if the isolation requirement is dropped.

Resume: Do NOT touch ANY metal part in a mains powered appliance and that includes ANY parts of ANY circuit (such as e.g. a Pi) that is directly connected to it.


Now for a solution to the problem of controlling such a device with a Pi. One of several is called "relay". A relay is a device where electrical power is converted to mechanical movement through a magnetic field. This movement is used to control a switch and (provided there is sufficient isolation between the switch and the magnetic field generating coil) one can operate a switch in a live circuit by providing a voltage to a coil that is safe to touch.

In practical terms: apply voltage to the relay coil by a GPIO pin (this requires some circuitry since the Pi GPIO does not provide sufficient current), connect the relay contact in parallel to the switch you want to control remotely and voilá, the switch is (virtually) operated by software control of a GPIO pin.

Some remarks on relay specification:
Choose coil voltage in accordance with the previously mentioned circuitry.
Choose contact rating in accordance with the circuit to control, in this specific coffee machine situation almost any relay will do.
Most important, choose a relay that provides the required isolation, not all do! So-called signal relays often don't, even if the contacts are specified for 500V. The thing to look for in the specification is a test voltage of 3500V (that is 3.5kV) (between coil and contacts) to meet EU requirements, I am not familiar with any US requirements.

Some remarks on mounting the relay and cabling. Since the purpose of the operation is to keep the live parts within the appliance enclosure the relay needs to fit IN the appliance, and please take care of a sturdy mount. Also make sure the coil controlling cabling is thouroughly isolated by e.g. shrink tubing. Requirements dictate at least 8mm (about 1/3 of an inch) distance to any live parts, but lower distances are allowed if there is sufficient isolation material thickness present in two seperate layers.

Please pay large amounts of attention to electrical safety, mains voltage is no child playtoy, lethal accidents have occured and will occur again, the best we can do is to keep numbers low.
Last edited by Stoomtronic on Mon Jan 05, 2015 7:28 pm, edited 1 time in total.

Stoomtronic
Posts: 5
Joined: Mon Jan 05, 2015 5:18 pm
Location: Netherlands

Re: Controlling a coffee maker with Raspberry Pi

Mon Jan 05, 2015 7:17 pm

joejoinerr wrote:
Gaijinsan wrote:Looking at the PCB. It seems that the on switch is activated by pulling the pin on the chip to ground. The best advice is to use a relay between the pi and the button.
So...
  • GPIO pin to the first (top) wire?
  • Ground pin to the second wire?
Have I got that right? So then turning on the GPIO will turn on the machine?

Nooooo, Do NOT connect your Pi (or anything you want to touch) directly to mains connected appliances. You may not only kill your Pi but possibly kill yourself also.

supersat
Posts: 2
Joined: Mon Jan 05, 2015 8:26 pm

Re: Controlling a coffee maker with Raspberry Pi

Mon Jan 05, 2015 8:36 pm

One of the reasons you shouldn't hook your Raspberry Pi directly up to the coffee maker is that without fully understanding how the coffee maker is constructed, you don't know whether "ground" on the coffee maker is "ground" on the Raspberry Pi. The difference can be as much as 120-240 volts! A relay or opto-isolators lets you galvanically isolate the two circuits so that their relative ground reference levels don't matter (to an extent which depends on the isolation rating).

Opto-isolators effectively work like a relay although they are usually polarized so you need to make sure you connect them properly. Relays shouldn't be driven directly from a Raspberry Pi -- the current used to energize the relay may exceed the current ratings of the GPIO pins, and you need some protection (such as a flyback diode) against the voltage spike on the coil when the relay turns off.

joejoinerr
Posts: 5
Joined: Sun Jan 04, 2015 7:59 pm

Re: Controlling a coffee maker with Raspberry Pi

Tue Jan 06, 2015 12:03 am

Stoomtronic wrote:
joejoinerr wrote:
Gaijinsan wrote:Looking at the PCB. It seems that the on switch is activated by pulling the pin on the chip to ground. The best advice is to use a relay between the pi and the button.
So...
  • GPIO pin to the first (top) wire?
  • Ground pin to the second wire?
Have I got that right? So then turning on the GPIO will turn on the machine?

Nooooo, Do NOT connect your Pi (or anything you want to touch) directly to mains connected appliances. You may not only kill your Pi but possibly kill yourself also.
I meant with the relay in between?

Stoomtronic
Posts: 5
Joined: Mon Jan 05, 2015 5:18 pm
Location: Netherlands

Re: Controlling a coffee maker with Raspberry Pi

Tue Jan 06, 2015 12:37 am

So...
  • GPIO pin to the first (top) wire?
  • Ground pin to the second wire?
Have I got that right? So then turning on the GPIO will turn on the machine?[/quote]


Nooooo, Do NOT connect your Pi (or anything you want to touch) directly to mains connected appliances. You may not only kill your Pi but possibly kill yourself also.[/quote]
I meant with the relay in between?[/quote]

Yes! The remaining issue is how to connect the relay contact and how to drive its coil. Connecting the coil directly to the Pi isn't going to work, it even may damage your Pi. What you need is a relay driver, see attached schematic.
Attachments
Relay-Sample.png
Relay-Sample.png (21.95 KiB) Viewed 6125 times

Stoomtronic
Posts: 5
Joined: Mon Jan 05, 2015 5:18 pm
Location: Netherlands

Re: Controlling a coffee maker with Raspberry Pi

Tue Jan 06, 2015 12:40 am

And instead of the AC1 and BL1 you need to connect the two blue horizontal lines on the right in parallel with the switch you want to control.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Controlling a coffee maker with Raspberry Pi

Tue Jan 06, 2015 6:07 am

joejoinerr wrote: I have no electronics knowledge whatsoever.
Now THAT is a problem.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

Stoomtronic
Posts: 5
Joined: Mon Jan 05, 2015 5:18 pm
Location: Netherlands

Re: Controlling a coffee maker with Raspberry Pi

Tue Jan 06, 2015 9:58 am

Without ANY electric or electronic knowledge it is seriously dangerous to mess with anything with a mains plug and I would strongly advise against it. You wouldn't be the first to hurt yourself, or worse.

joejoinerr
Posts: 5
Joined: Sun Jan 04, 2015 7:59 pm

Re: Controlling a coffee maker with Raspberry Pi

Tue Jan 06, 2015 10:18 am

Richard-TX wrote:
joejoinerr wrote: I have no electronics knowledge whatsoever.
Now THAT is a problem.
Now you see why I posted the idea here first ;)

I thought it would be a simple two pin, two cable task since I was only outputting from the RPi, but I'm beginning to realise the implications now…

anita2r
Posts: 226
Joined: Sun Dec 23, 2012 6:55 pm
Location: Ottawa, Canada

Re: Controlling a coffee maker with Raspberry Pi

Tue Jan 06, 2015 9:12 pm

Hi,

Why not start by purchasing one of those plug-in safety devices used to protect against electric shock. They have different names in different countries, such as ground fault interrupter or earth leakage circuit breaker. They are often sold for providing protection when using mains supplied devices out of doors.

Now if you come into contact with a mains voltage in the coffee maker (cm) you should be protected against being shocked, and although the Pi may be damaged it won't pose a serious risk to you.

Once the cm is plugged in via the protection device, you can test the circuit board for any mains voltages - unlikely, but lets be sure.
With a test meter set to AC and a mains voltage range, put the black probe onto a solid grounded/earthed piece of metal, and use the other probe to test each of the pads on the connector. As the connector is the only source of voltage for the pcb, if none of the pads registers a mains-like voltage, then the pcb is a low voltage device. If a mains-like voltage is seen STOP.

There is a theoretical possibility that the cm has an isolating transformer providing mains voltage but isolated from ground. To test for this, keep the meter set to AC and a mains voltage range and test all possible combinations of the four connector pads. No mains-like voltage will be seen from any combination. If it is STOP.

Now turn the meter to a low voltage DC setting and test the connector pads again, this time placing one probe on one pad and the other probe on each of the other three pads in turn. Repeat by moving the first probe to the second pad and so on. You should find a combination that registers a low DC voltage, perhaps 5 volts. Identify which is positive and which is negative. If the display shows a positive voltage , then the pad that the red probe is on is +ve. If the meter shows a negative voltage, then the pad that the black probe is on is +ve.

This will confirm the operating voltage of the pcb and which pads provide this low voltage (and which one is +ve)
Using the meter again, connect the black (-ve) probe to the continuous track along the bottom of the switches and touch the red +ve probe to the +ve connector pad. If the meter shows a positive voltage, then the long track is negative - which is what is more likely.

Next with the power off and the connector disconnected, use a resistance range on the meter to test the ON switch.
Is it a click-on click-off switch or is it only 'on' when pressed - a momentary contact switch.

This will determine how to control the cm.

Once you know these things, then a decision can be made on how to control it.

A relay seems like overkill for this issue. The switch is connected to some form of microprocessor and the current required is minute. A simple transistor will likely be sufficient to make the connection that the switch makes.
The transistor can then be controlled by a gpio on the Pi.
In an excess of caution, the transistor base can be connected to the Pi through an optoisolator.

If the pcb track along the bottom of the four switches is indeed negative (ground) then switching with an npn transistor should be straightforward.

The Pi then either provides a momentary on state, then off again, or just provides an on state until you are ready to switch it off, depending on what you found when testing the switch.

Regards

anita2R

Return to “Automation, sensing and robotics”