Computing stuff tied to the physical world

Snooping with an Optocoupler

In Hardware on Nov 28, 2012 at 00:01

The thing with OpenTherm, is that the amount of current going through the wire is used by the boiler to send messages to the thermostat.

The reverse path, i.e. from thermostat to boiler, is signalled by voltage changes, which are considerably easier to detect. So let’s save that for later.

There is a small complication, in that the polarity of the wiring between boiler and thermostat is not defined, so either one of them could be “”+” and “-”, respectively. Of course once you’ve hooked things up, that polarity never changes again.

Can we measure the current going through a wire, without knowing in which direction it is flowing? We know it’ll be 5..7 mA for one signalling state and 20..25 mA for the other.

Here’s what I came up with:

There are two optocouplers in there, with the diodes connected in opposite ways. Depending on the direction of the current, one of them will block and the other one will light up – once the voltage over the 82 Ω resistor exceeds about 1V, i.e. at ≈ 12 mA.

For documentation purposes, the actual build:

The voltage drop over this circuit is at most just over 1V, which may or may not interfere with proper operation of the boiler and thermostat. Testing will be needed to find out.

The first advantage of this circuit is that it works with either polarity without needing a bridge rectifier (which would introduce yet another voltage drop). In addition, the output signal is galvanically isolated from the OpenTherm loop, i.e. “floating”. That means it can be connected in whatever way is needed.

The second part of an “OpenTherm snooper” – if it ever materialises – will be to measure the voltage between the wires and hopefully also to self-power the rest of the circuit. Note that the optocoupler LED lights up when a high current is passing through, and this is also the state where the photo transistor is drawing more current through the 10 kΩ resistor.

Here’s the diode voltage (yellow) and output (blue), using the same ± 10V @ 50 Hz signal as yesterday. The vertical zero axis is one division down from the centre, for both traces:

Note how the output triggers on both positive and negative excursions of the input signal due to the anti-parallel LEDs, which is why it ends up having twice as many pulses. So the first half is one LED turning on and off, and the second half is the other LED – both lead to the common OUT pin being pulled down. For OpenTherm use, there’d never be both polarities – only one LED would be active, depending on how the circuit is connected.

The pulse-width asymmetry you see is an artefact of the way the sine wave is applied (using a 150 Ω resistor). This will not happen with a 7..25 mA current toggle and 82 Ω. And while the MCT62 is not one of the fastest optocouplers, especially with a 10 kΩ collector pull-up, I expect that the resulting pulses will still be accurate enough.

So far so good. I haven’t built the rest yet – just doodling and trying to figure it all out.

1. Hello Jean-Claude,

I did not understand why you’re trying to create one alternative physical interface. The interface in the project openthermgateway not work as expected?

Does it is related to the issue identified in the article “Bi-directional signalling and power” ?

Regards

Mirko Ugolini

• The problem I see with my current setup, is a floating loop vs. powerline grounding issue. The setup works better when grounding the OTG – thermostat loop, but still not 100%. I’m not sure what’s going on, it could also be the code in my JeeNode.

These experiments are an attempt to create a self-powered unit, i.e. drawing the necessary current from the boiler itself and getting rid of the galvanic isolation between boiler and thermostat. There are other ways to do this, so I’m actually going to try it without opto-coupler, but wanted to get these notes out for anyone who is interested.

2. I take it the boiler and thermostat have no problems coping with the voltage drop over your 82R?

• I haven’t tried it yet. The drop will be 0.6 .. 1.1V, it might indeed be a bit much (official in-line resistance should not exceed 2×5Ω, i.e. up to 0.25V drop).

3. In the process of building the JeeTherm (see http://jaagpad.blogspot.nl/2012/09/jeetherm-update.html) I also found out that it needed a small resitor (i’m using 100 Ohm) added to that schematic parallel to the optocoupler for measuring the current signal of the boiler. Seems like a good example of Multiple Discovery.

4. You mean, similar to the 82 Ω shown in the above example? Yes, that is essential to raise the detection level to the proper value.

5. Hello all, If the problem if to reduce the 82 ohm resistor in series to the line in order to respect the opentherm specifications… What about to use one darlinghton optocoupler?

• That won’t make a difference, I’m afraid. The voltage drop has to be around 1.1V to make the IR LED inside the optocoupler light up.