Operation
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):
Sensor Register Count (2 bytes):
Request
Modbus TCP Request Frame Example – Read Sensor 1 and 2
Field Name
Transaction Identifier
Protocol Identifier
Message Length
Unit Identifier
Function Code
Data
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
Transaction Identifier
Protocol Identifier
Message Length
Unit Identifier
Function Code
Data
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
0x0110, 0x0112 ... 0x011E (Sensors 1, 2 ... 8 respectively)
0x02, 0x04 ... 0x10
Length
Function
2 bytes
Synchronization number.
2 bytes
Zero for Modbus/TCP
2 bytes
Number of bytes in frame (below)
1 byte
Slave Address (0xff if not used)
1 byte
Read Sensors
3 bytes
Start Address (0x0110, 0x0112 ...
0x011E)
Sensor Count (0x02, 0x04 ... 0x10)
Length
Function
2 bytes
Synchronization number.
2 bytes
Zero for Modbus/TCP
2 bytes
Number of bytes in frame (below)
1 byte
Slave Address (0xff if not used)
1 byte
Read Sensors
10-14
Byte Count (0x04 – 0x0C)
bytes
Sensor Value (0x00000000 – 0xFFFFFFFF)
Sensor Value (0x00000000 – 0xFFFFFFFF)
WebRelay-10 Users Manual
Example Data
0x0001
0x0000
0x0005
0xFF
0x03
0x0110
0x0004
Example Data
0x0001
0x0000
0x000C
0xFF
0x03
0x0008
0x999A41B1
0xB85142D2
Xytronix Research & Design, Inc.
Need help?
Do you have a question about the WebRelay-10 X-WR-10R12-I and is the answer not in the manual?
Questions and answers