Transmission of commands via the serial interface

This Forum is about the Opentherm gateway (OTGW) from Schelte

Moderator: hvxl

Post Reply
chino
Starting Member
Starting Member
Posts: 7
Joined: Sun Nov 23, 2014 6:15 pm

Transmission of commands via the serial interface

Post by chino »

Hello everybody,

I'm setting up an opentherm gateway to control my boiler with a Raspberry Pi. My idea is to have a script (either unix shell, perl or python) that can send setpoints to the boiler (following the description in http://otgw.tclcode.com/firmware.html#configuration).

After hooking up the otgw between the thermostat and the boiler, I tried to read the communication via the serial interface. From the shell of my linux box, the following commands:

stty -F /dev/ttyUSB0 9600
cat /dev/ttyUSB0

gave me this (continuous) output

BC0394100
T80190000
B40192200
T10010A00
BD0010A00
T80000200
..........

My problem at this point is that I do not know how to translate the serial commands (e.g. Command: "CS=45.8") to this transmission protocol. With some sort of reverse engineering I was able to find out that the last 2 bytes are indicating the value of a command. But the rest is not really clear!

I don't know if I'm missing something obvious, but I'm really stocket at this point ... It would be great if anybody could help!

Regards,
Carlo
hvxl
Senior Member
Senior Member
Posts: 1965
Joined: Sat Jun 05, 2010 11:59 am
Contact:

Re: Transmission of commands via the serial interface

Post by hvxl »

As described on the web site, those reports you see are the opentherm messages being exchanged between the thermostat and the boiler. Use the opentherm specification to decode them.

The serial commands described on the same page are understood by the gateway. You don't need to apply any translation to them. Just send them exactly like that to the gateway, terminated by a CR.

To my mind I've described all of this clearly on the web page. Can you indicate why you were having trouble understanding it, so I can possibly improve the text?
Schelte
chino
Starting Member
Starting Member
Posts: 7
Joined: Sun Nov 23, 2014 6:15 pm

Re: Transmission of commands via the serial interface

Post by chino »

Hi Schelte,

thank your for your response! Now it's clearer and indeed in the meantime I tried a test connection with minicom where in fact I was able to see the opentherm messagges and, by giving a serial command, I was receiving the correct reply as indicated in the instructions on your web page.

You web page is in my opinion clear and well explained. I think that my confusion arised because of my inexperience with serial communications combined by the fact that my script in python was able to read the serial port but not to write. So I began wondering if I did not have somehow to convert the commands from plain text to the opentherm messages format.

However, perhaps a little example (maybe in the section "Serial commands") with an example script and a little log of the serial port communication could be beneficial for people with less experience.

My script for sending commands to the boiler is not working yet (it can only read but every write effort is ignored ...) but as soon as it will be functioning, if you want to include as example in your web page, I would be happy to share it. Or on the other side if you already have a functioning script that you want to share, I would not mind to accept it :-)

Maybe interesting for you: I have a FS20 based heating system, connected with a raspberry pi running fhem. FS20 can itself control your boiler but only with on/off. So I want to make the raspberry pi modulating the boiler, based on the requests from the different rooms. The boiler is a Nefit (with proprietary transmission protocol) interfaced to opentherm with a converter. As soon as everyting is up and running I will make a list of the open therm messages that I was able to exchange with the boiiler, if you want to include it in your equipment compatibility matrix.

Regards,
Carlo
chino
Starting Member
Starting Member
Posts: 7
Joined: Sun Nov 23, 2014 6:15 pm

Re: Transmission of commands via the serial interface

Post by chino »

Little update: writing commands to the serial port works now also in python (with pyserial) :-)
The reason why it was not workign before is that I was setting the hardware flow control to off. I thought it had to be off because there are no wires for RTS and CTS on the opentherm gateway, so I still do not understand why it works only with rts on ... but as I said I don't have much experience with serial communications...
hvxl
Senior Member
Senior Member
Posts: 1965
Joined: Sat Jun 05, 2010 11:59 am
Contact:

Re: Transmission of commands via the serial interface

Post by hvxl »

I did provide an example program: otmonitor. However I have to admit, due to all the features requested by users, it's not little anymore. :-)
Schelte
chino
Starting Member
Starting Member
Posts: 7
Joined: Sun Nov 23, 2014 6:15 pm

Re: Transmission of commands via the serial interface

Post by chino »

I used otmonitor from my laptop to test if everything was working properly. It is a great program and I was amazed how accurate you made the user interface! However, for my application I have to send serial commands calculated from another program running on my raspberry pi and this is not possible with otmonitor (or at least I did not find a way to do it). That's why I was looking for a simple script to send the commands to the serial interface.

In any case, you did a great job with both the opentherm gateway hardware and otmonitor software :-)
mike7
Member
Member
Posts: 102
Joined: Mon Dec 02, 2013 8:45 am

Re: Transmission of commands via the serial interface

Post by mike7 »

You can send commands with otmonitor, I know 3 ways:
1 - http, http://yourip:port/command?PR=C (you should enable web server)
2 - dbus, description on http://yourip:port/dbus.html
3 - use remote access port, with the last version you can also read messages

PS. otmonitor also support mqtt
arno
Starting Member
Starting Member
Posts: 6
Joined: Fri Dec 12, 2014 11:29 pm

Re: Transmission of commands via the serial interface

Post by arno »

Dear chino,

Can you give me a high level setup of your system to control the NEFIT ? I have build my own climate control ( with Netduino in .NET and LAMP for the GUI and datahandling ) including controlling my NEFIT HRC 24 Smartline ( from 2004 ) with on/off control. It works fine but I am looking to add control via OpenTherm to benefit from the HR capabilities by e.g. setting a modulation level.

Looking forward to your response.

Br,

Arno
chino
Starting Member
Starting Member
Posts: 7
Joined: Sun Nov 23, 2014 6:15 pm

Re: Transmission of commands via the serial interface

Post by chino »

Hallo Arno,

sorry for my late reply. In short and high level:

I have an opentherm converter which I purcased from http://www.homewizard.nl/, to this converter I have connected the opentherm gateway from http://otgw.tclcode.com/. There is no thermostat connected to the opentherm gateway. I have fhem running on a raspberry pi, the rasperry pi is also connected to the opentherm gateway via usb.

On the raspberry pi, I run a perl script that gathers the setpoints for the radiators, determines the required water temperature from the boiler and sends the appropriate command to the opentherm gateway (=> onetherm converter => boiler).

Please let me know if you need any more details. If you are interested I can also share my perl script with you.

Regards,
Carlo
arno
Starting Member
Starting Member
Posts: 6
Joined: Fri Dec 12, 2014 11:29 pm

Re: Transmission of commands via the serial interface

Post by arno »

Hello Carlo,

Thanks a lot for your response. I would be very interested to get a copy of your script to see what I can re-use in terms of setup's on my Netduino.

Looking forward to your feedback,

Br,

Arno
Ghostbird
Starting Member
Starting Member
Posts: 14
Joined: Wed Mar 11, 2015 8:03 pm

Re: Transmission of commands via the serial interface

Post by Ghostbird »

I'm running on a raspberry pi too. I used minicom to manually communicate with the interface.

Note: I used /dev/ttyAMA0 as communication point (built-in 3.3V TTL serial port) because I modified my OTGW. I replaced the MAX232 with a 2-channel 3.3V/5V level converter so the PIC interfaces directly with the RPi serial port trough the level converter.

These are my minicom default settings from /etc/minicom/minirc.dfl, you can copy these, though you may have to change the port setting.

Code: Select all

# Machine-generated file - use "minicom -s" to change parameters.
pu port             /dev/ttyAMA0
pu baudrate         9600
pu localecho        Yes
Ensure you have read/write access to the device you want to use. In my case this was easy since the serial port is set up for use by the group dialout:

Code: Select all

adduser pi dialout
Then re-login and start minicom using defaults:

Code: Select all

minicom
Now you can send messages like: PR=A
If successful this will print the Gateway version information.

Note: The gateway does not understand backslashes, so if you make an error while typing, you cannot correct it. Instead turn the command into something incomprehensible and send that. That way the gateway will just ignore it and reply SE (Syntax Error) and you can try again.
arno
Starting Member
Starting Member
Posts: 6
Joined: Fri Dec 12, 2014 11:29 pm

Re: Transmission of commands via the serial interface

Post by arno »

Hi Guys,

Thanks for all the feedback. What I would like to know (more) is if you control the boiler temperature from your SW. In my current climate control application I calculate a boiler temperature based on a formula using the outside temperature. The warmer outside, the colder the boiler temperature. At the moment I am controlling the boiler via an (advanced) on-off system where every 10 minutes I compare the average boiler temperature with the calculated set point and from this derive a heating time for the burner of the boiler. It is like a samples system with a 10 minute interval. It works fine but I think with using the modulation from the boiler I can be more economic using the gas. However, then I must be able via OpenTherm to set the boiler temperature ( and not the thermostat set-point ).

Looking forward to your answers,

Arno
Post Reply

Return to “Opentherm Gateway Forum”