Your wiring schematic doesn't show a common ground between the heatmiser and the arduino. It needs one.
Also are you sure those lines are the right way round?
The RS485 is a half duplex connection, I can't see anywhere in the code where you enable and disable the transmit / receive buffers?
Finally what software protocol does the heatmiser use? Does it need talking to before it will give you anything back. There is a RS485 protocol library, why are you not using that?
The serial monitor is now displaying a series of raw bytes.
But In order to make sense of these I think I need to set my serial communication parameters.
According to the Heatmiser protocol I need to set my serial communication parameters as follows: 4800bps, data: 8 bit, start: 1 bit, stop: 1 bit, no parity check.
But I am not sure how to go about setting these in the sketch?
Is this where I need the RS485 protocol library that you were talking about?
If so, where can I find it?
The Heatmiser Protocol instructions for this are as follows:
The master always initiates communications by sending a command string to the destination thermostat to read or write to some or all of the Data Control Block. Reading Data from the system N.B. broadcast address cannot be used in read mode We recommend that when reading devices that the entire DCB is read subject to the master having sufficient ram to hold the data. The following command reads the entire DCB: xx 0a ** 00 00 00 ff ff ## ## where xx =destination slave address, [1, 32] 0a =frame length ** = source master address, [81, a0] 00 = read 00 00 = read start location, in this case the first byte of the whole DCB ff ff = read the whole data of DCB ## ##: low and high 8 bit of 16bit crc check
Now all I need to do is make sense of the Heatmiser Protocol instructions and figure out how to formulate this command string?
Can anyone help me make sense of this?
i.e. how do I know what the destination slave address is(i.e. the address of the thermostat)?
or the 'source master address(address of the arduino)?
and what is the frame length or the crc check bit high and low?
The Heatmiser Protocol instructions show an example for sending a command string as follows:
To query no.2 thermostat:
Send(Hex): 02H, 04H, 00H, 06H
The first unit(02H) is the address of the thermostat, the second(04H) is the request code asking the thermostat for its stats. I don't know what the third one is so we will leave it as it is in the example. Finally, the last unit(06H) is the checksum of all the preceding units.
Because I only have one Thermostat wired in, I am going to assume that its address is 01H and therefore I am going to use the following code to try and send this (01H, 04H, 00H, 05H) from the arduino to the thermostat:
The statement you wrote says "Send the fifth byte from the req array", but what you want is "Send the first 4 bytes from the req array".
One of the disadvantages of the way C++ lets you declare multiple forms of the same function is that the compiler can't detect errors like this the way a C compiler can. Think of it as "polymorphism perversity"...