Operation
WebRelay-10 Users Manual
3.4.6 Read Sensors – Modbus Function Code 03 (0x03) (WebRelay-10 Plus™ only)
The Read Holding Registers function is used for the temperature or humidity sensors.
32-bit sensor values are read from 16-bit register pairs. Consequently, senors addresses and registers
must be even numbers.
Start Address (2 bytes):
0x0110, 0x0112 ... 0x011E (Sensors 1, 2 … 8 respectively)
Sensor Register Count (2 bytes):
0x02, 0x04 ... 0x10
Request
Modbus TCP Request Frame Example – Read Sensor 1 and 2
Field Name
Length
Function
Example Data
Transaction Identifier
2 bytes
Synchronization number.
0x0001
Protocol Identifier
2 bytes
Zero for Modbus/TCP
0x0000
Message Length
2 bytes
Number of bytes in frame (below)
0x0005
Unit Identifier
1 byte
Slave Address (0xff if not used)
0xFF
Function Code
1 byte
Read Sensors
0x03
Data
3 bytes
Start Address (
0x0110, 0x0112 ...
0x011E
)
Sensor Count (
0x02, 0x04 ... 0x10
)
0x0110
0x0004
TX String: 00 01 00 00 00 05 FF 03 01 10 00 04
Response
Each value is returned as two registers in IEEE 754 floating point formats. The four data bytes are
treated as two individual big-endian 16-bit words with the least significant word being sent first. In other
words, the 32-bit floating point number represented as '1234 ABCD' is sent as ABCD 1234.' For
example, if we were to read two registers starting at address 0x110, and Sensor 1 measured the
temperature to be 81.25 degrees, then we would get the following value 800042A2. The least significant
word would be 8000 hex and the most significant word would be 42A2. Using a conversion utility, we
could then convert this hexadecimal value into the temperature reading of 81.25 degrees.
The device returns a value of 0xFFFFFFFF (NaN) if there isn't a valid reading or when the sensor isn't
active.
WebRelay-10 Response Frame Example – Sensor 1 and 2
Field Name
Length
Function
Example Data
Transaction Identifier
2 bytes
Synchronization number.
0x0001
Protocol Identifier
2 bytes
Zero for Modbus/TCP
0x0000
Message Length
2 bytes
Number of bytes in frame (below)
0x000C
Unit Identifier
1 byte
Slave Address (0xff if not used)
0xFF
Function Code
1 byte
Read Sensors
0x03
Data
10-14
bytes
Byte Count (0x04 – 0x0C)
Sensor Value (0x00000000 – 0xFFFFFFFF)
Sensor Value (0x00000000 – 0xFFFFFFFF)
0x0008
0x999A41B1
0xB85142D2
RX String: 017-Rx:00 01 00 00 00 0B FF 03 08 99 9A 41 B1 B8 51 42 D2
Errors
Sensor Read Error Function Code (1 byte): 0x83
page 70
Xytronix Research & Design, Inc.