1. 05 (0x05) write single coil output
Use this function code to write a coil output to the remote address, and the coil state is only 0 or 1.
2. Send message format
The more detailed format is as follows:
MBAP message header + function code + high bit of coil address + low bit of coil address + high bit of output value + low bit of output value, a total of 12 bytes.
3. Return message format
The more detailed format is as follows:
MBAP message header + function code + high bit of coil address + low bit of coil address + high bit of output value + low bit of output value, a total of 12 bytes.
4. Case
Slave station address: 1
Coil address: 5
Output value: ON (0xff00)
Suppose you want to set the slave station address as 1 and the coil with address 5 as ON, then
4.1 Send the message as follows:
The meaning of each byte of 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x01, 0x05, 0x00, 0x05, 0xff, 0x00 is as follows: