Monday, July 4, 2011

OpenTherm success

I have been waiting for someone to connect an arduino to a boiler using OpenTherm. Someone has managed to use some circuit and an arduino to listen, but I want to be able to send messages as well.

So, I read and reread the OpenTherm standard which is available, v2.2, and have been cooking a solution.

The thing is a current loop, so to read it, one doesn't need more then an optocoupler. to control it, one has to vary the voltage between around 5V and 17V, but the boiler provides a fixed current. So, if the current is fixed and you want (have) to change the voltage, you need to change the resistance.

My plan was then to use two optocouplers, one to read, and one to write the messages. Here is my circuit:
I used a 4N27 and not a 4N35 as in the diagram. The boiler connects at the terminals at the right, and the bridge is also an integrated bridge. The boiler side resistor is 2.2K and 1W, so not the normal low power resistors!! The arduino resistor is a 220 to drive the led.

I haven't yet connected the output of the other optocoupler, the receiver one, but that should not be much work, the worse is to detect and decode the pulses, but for that someone also wrote a library (see link above).



And the good news, is...it works! or at least I think it does...

I tried first doing a PWM control, corresponding to OpenTherm lite (OT-) as defined in the standard, but my boiler doesn't seem to support that, so I wrote a manchester encoder, and sent a message to the boiler, and the boiler replied. It uses interrupt driven code to deliver the pulses with the proper timing.

I haven't actually decoded the reply yet, or sent any real commands to the boiler, I only saw the reply from the boiler in the oscilloscope. Images and code will follow soon...the camera had no battery to take a picture of the oscilloscope in that moment of glory!

6 comments:

João Silva said...

Great News! and Great Work!

Darren said...

Hello!

You have done really great work on this and I am trying repeat it using some different boilers. I've got the transmitting part working but I'm getting nowhere with the current sensing section :-((. How does the opto isolator function as a current sensing device? I've tried rigging up some basic circuits to try and understand the problem but I can't get the opto isolator to switch according to current levels. Any help is much appreciated.

Darren said...

Never mind! I have found out how critical the valve of R2 is. In my circuit/boiler combination, it is 268 ohms. Onward to the next stage then...

Alex said...

Hello Darren!
Sorry for the loooong delay in comming back to you.
Indeed it is a fiddly job to find the correct value for R2, such that the current passing through the optocoupler turns its output just high or low enough to be detected by the microcontroler as a change in level.
Glad you sorted it out! and I hope you managed to achieve what you were trying!
I am now working on a version of the circuit powered directly by the boiler...a small preview is at the blog of my friend who is helping out (doing all the hard(ware) work)

http://bitsnbikes.blogspot.nl/2012/01/opentherm-v2-first-prototype.html

gritman said...

Hallo Alex,
when compiling OY_listener, I keep getting the message: FSM/FiniteStateMachine.h:33:22: fatal error: WProgram.h: No such file or directory
#include .
I use version 1.6.2 and as of version 1.x WProgram.h should be replaced by Arduino.h, but still no luck. Which version did you use to compile?

Alex said...

Hello Gritman!

And sorry for the huuuuge delay...family affairs...

Hope you solved your problem by now, because indeed I used an older version of Arduino to compile. I think something before 1.0 (maybe 0.9?). Later I tried with a newer version for a firmware upgrade, and I got the same error...but never bothered to upgrade the code, as it would mean retesting of most functionality.