Help wanted: Controlling multiple OpenTherm thermostats with one Arduino

Briefly: An OpenTherm (OT) thermostat controls a boiler with a 32 bits command. This command is sent by Manchester coding. There are a few topics about handling the code and the commands, e.g. - https://github.com/amvv/ArduinoOpenTherm (software) - http://otgw.tclcode.com/index.html (hardware) - http://www.gammon.com.au/forum/?id=11488 (all about interrupts)

Above helped me to make an Arduino controlled OT gateway, which is working fine. For the final step in my home automation project, I need to control 6 OT thermostats (each room has its own thermostat). At this point it becomes quite complicated, maybe some can help me out!

The facts: - with OT, the thermostat is master, the boiler (or now: Arduino) is slave - there's no way to control the thermostat via Arduino: Arduino is only answering at questions of the master - each bit (of total of 32 +2 start/stop bits) takes 1msec - because of manchester coding, a level change could occur at 500 microseconds - the thermostat is communicating once in a second - within 800msec, the slave has to answer the master - the slave MUST anwer the master (otherwise the master stops communicating)

The problem: Above was possible with one thermostat. But I encountered lots of problems with multiple (6) thermostats: - each thermostat acts as a master, which means that different commands of different thermostats arrives 'mixed up' in Arduino (e.g.: when handling bit 17 of thermostat One, startbit of thermostat 2 is incoming). - while controlling incoming commands, I have to generate an answer for the resp. thermostat, as well controlling the boiler and heating zones. (- for even more fun, I have to calculate a parity bit for each command) - finally, I need I2C to communicate with the rest of my HA (another Arduino, Mega). This means: in case of a Mega, only 4 interrupts are left.

Anyone has some ideas or tips? Is it even possible with one Arduino?

First see blink without delay, this shows you how to do things without blocking/delays.

Next look at arrays. many of the same thing.

Add this the a FSM (Finite State Machine) look in the playground

and the jobs done

Mark

Kong: The facts: - with OT, the thermostat is master, the boiler (or now: Arduino) is slave - there's no way to control the thermostat via Arduino: Arduino is only answering at questions of the master - each bit (of total of 32 +2 start/stop bits) takes 1msec - because of manchester coding, a level change could occur at 500 microseconds - the thermostat is communicating once in a second - within 800msec, the slave has to answer the master - the slave MUST anwer the master (otherwise the master stops communicating)

You need to explain this in a lot more detail before I can follow it. And I suspect the greater detail would help you as well.

Try to write down on a separate line every step that the code must take.

If you get a signal from each of 6 devices once per 1000 msecs and each must receive a response within 800 msecs there should be no difficulty in servicing them all if a typical transfer only takes 1 msec.

If all the communication must take place on the same I/O pins there may be a risk of two devices starting to talk at the same time unless your master can control when they send. I could see that sort of collision escalating into total chaos if you are not careful.

...R

Both thanks for answering. @Mark: I've seen this FSM, have googled it, but what it's doing is not quite obvious to me. When you say this will do the job, I'll have a second look at it. @Robin, I will see if I can make a schematic of what should (or could) happen with the 6 thermostats bit sequences. Give me some time to work things out.