Computing stuff tied to the physical world

OpenTherm relay

In Software on Nov 20, 2012 at 00:01

Now that the OpenTherm Gateway has been verified to work, it’s time to think about a more permanent setup. My plan is to send things over wireless via an RFM12B on 868 MHz. And like the SMA solar inverter relay, the main task is to capture the incoming serial data and then send this out as wireless packets.

First, a little adapter – with 10 kΩ resistors in series as 5V -> 3.3V “level converters”:

DSC 4253

(that’s an old JeeNode v2 – might as well re-use this stuff, eh?)

And here’s the first version of the otRelay.ino sketch I came up with:

Screen Shot 2012 11 11 at 00 26 19

The only tricky bit in here is how to identify each message coming in over the serial port. That’s fairly easy in this case, because all valid messages are known to consist of exactly one letter, then 8 hex digits, then a carriage return. We can simply ignore anything else:

  • if there is a valid numeric or uppercase character, and there is room: store it
  • if a carriage returns arrives at the end of the buffer: bingo, a complete packet!
  • everything else causes the buffer to be cleared

This isn’t the packet format I intend to use in the final setup, but it’s a simple way to figure out what’s coming in in the first place.

It worked on first try. Some results from this node, as logged by the central JeeLink:

  L 10:38:07.582 usb-A40117UK OK 14 84 56 48 49 65 48 48 48 48
  L 10:38:07.678 usb-A40117UK OK 14 66 52 48 49 65 50 66 48 48
  L 10:38:08.558 usb-A40117UK OK 14 84 56 48 49 57 48 48 48 48
  L 10:38:08.654 usb-A40117UK OK 14 66 52 48 49 57 51 53 48 48
  L 10:38:09.566 usb-A40117UK OK 14 84 49 48 48 49 48 65 48 48
  L 10:38:09.678 usb-A40117UK OK 14 66 68 48 48 49 48 65 48 48
  L 10:38:10.574 usb-A40117UK OK 14 84 48 48 49 66 48 48 48 48
  L 10:38:10.686 usb-A40117UK OK 14 66 54 48 49 66 48 48 48 48
  L 10:38:11.550 usb-A40117UK OK 14 84 48 48 48 70 48 48 48 48
  L 10:38:11.646 usb-A40117UK OK 14 66 70 48 48 70 48 48 48 48
  L 10:38:12.557 usb-A40117UK OK 14 84 48 48 49 50 48 48 48 48

One of the problems with just relaying everything, apart from the fact that it’s wasteful to send it all as hex characters, is that there’s quite a bit of info coming out of the gateway:

Screen Shot 2012 11 10 at 22 44 51

Not only that – a lot of it is in fact redundant. There’s really no need to send the request as well as the reply in each exchange. All I care about are the “Read-Ack” and “Write-Data” packets, which contain actual meaningful results.

Some smarts in this relay may reduce RF traffic without losing any vital information.

  1. an opentherm gateway with integrated jeenode would be a great addon for the shop :-)

  2. If I am not mistaken, the boiler always returns the data sent to it by the master when issued with a ‘write’ command, and, logically, returns the data requested when issued a ‘read’ command, so all you need to know what is going on is to listen to the replies, as they have all the info of the requests. Now, the reply from the boiler is done in current, changing the current between around 5mA and 20mA, so a very simple listener is an optocoupler inserted in the line. It can then just eavesdrop on what is happening without disturbing the communication between boiler and thermostat, and avoiding all the complication of the gateway. The optocoupler LED has to be placed with the right polarity, so that takes a maximum of 2 tries, but then you have a listening device, which can drive an interrupt pin of the JeeNode, and, since there are only 32 (bits) transitions every second, you can have one of your nice power saving JeeNodes battery powered listening and transmitting for months on end!

    • You’ve been reading my yet-to-be-published posts! Or maybe you’re a mind reader? :)

    • Now I’ll have to stay awake until midnight again…I always wondered if it would really work…

    • Contrary to a stubborn belief, this is a weblog where weblog posts appear at midnight, not vanish !!!

  3. JC, the gateway also supports polling (PS=1). If the JeeNode issues this command every 5 minutes then you receive a certain set of ‘relevant’ msgid’s also every 5 minutes…

Comments are closed.