Sensorex Modbus User Instruction (Rev 1.1)
Sensorex Modbus User Instruction (Rev 1.1)
Sensorex Modbus User Instruction (Rev 1.1)
Thank you for choosing Sensorex Smart Sensor products. This instruction manual is provided to guide the user in the
use of the smart sensor products. It covers all aspects of programming and communication for the sensors. If any
question not covered in this document arise, please contact your Sensorex supplier or [email protected]
Sensor Wiring:
Wire Color Function
Red V+ (7‐40VDC in Modbus mode)
Black V‐
White Modbus A
Green Modbus B
2021-5-12 P a g e 1 | 18
Sensorex Smart Sensor Modbus User Instruction Rev. 1.0
Table of Contents
1. Device Address ..................................................................................................................... 3
2. Baud Rate ............................................................................................................................. 3
3. Data Format .......................................................................................................................... 3
4. Read Register (Function Code 03/0x03) ............................................................................... 4
4.1 Modbus Read Query Message .......................................................................................... 4
4.2 Modbus Read Response Message ................................................................................... 4
5. Write Single Register (Function Code 06 / 0x06) .................................................................. 5
5.1 Unlock Write Protection ..................................................................................................... 5
5.2 Modbus Write Query Message .......................................................................................... 6
6. Write Multiple Registers (Function Code 16 / 0x10) .............................................................. 7
6.1 Unlock Write Protection ..................................................................................................... 7
6.2 Modbus Write Query Message .......................................................................................... 7
6.3 Modbus Write Response Message .................................................................................... 7
7. Sensor Measurement Data Register ..................................................................................... 9
7.1 Probe Value, Temperature and Alternate value ............................................................ 7
7.2 Probe Raw Value .............................................................................................................. 7
8. Sensor Calibration Data Register ........................................................................................ 10
8.1 Calibration Data Storage ............................................................................................. 10
8.2 User Calibration ............................................................................................................. 9
8.3 Temperature Calibration .............................................................................................. 10
8.4 Free Chlorine sensor Calibration will be added up later .............................................. 10
9. Operation Mode and 4-20mA Scale Setup ......................................................................... 12
9.1 Operation Mode ........................................................................................................... 10
9.1 Current Loop 4-20mA Scale Setup .............................................................................. 10
10. Temperature Coefficient Data Register ............................................................................... 12
11. Firmware Version ................................................................................................................ 12
12. Model Number ..................................................................................................................... 12
13. Serial Number ..................................................................................................................... 13
14. User label ............................................................................................................................ 13
15. Manufacture Date ................................................................................................................ 13
16. Exception Responses and Exception Codes ...................................................................... 11
16.1 Exception Responses ...................................................................................................... 13
16.2 Exception Codes ............................................................................................................. 14
17. Sensor Soft Reset ............................................................................................................... 15
18. Sensorex Modbus Register List .......................................................................................... 15
2021-5-12 P a g e 2 | 18
Sensorex Smart Sensor Modbus User Instruction Rev. 1.0
Modbus is a simple and robust standard communication protocol. Sensorex Smart Sensor is
designed to function as a Modbus Slave on a multi-drop RS485 serial connection using the
Modbus RTU (remote terminal unit) protocol. Please refer to Modbus Application Protocol
Specification V1.1b3 (April 26, 2012) for more detailed about each protocol specification. The
Remote Terminal Unit serial protocol is described in MODBUS over Serial Line, Specification and
Implementation Guide, V1.02.
Each sensor has four wires: two for RS485 (white is A, green is B) and two for power (red is V+,
Black is V-). When in the Modbus mode, a Modbus master devise can read and configure the
sensor. Since RS-485 uses half-duplex communication, master switches to transmitting state to
send a command then switches to receiver state and waits for a response. The waiting time for
master to receive a response should be at least 200 milliseconds for the slave to process the
command and send out the response.
It is important to remember that all setup changes requires a power (on then off) cycle or soft
reset to accept any changes.
Sensorex Smart Sensors are capable of reading and writing in the 4-20mA loop current mode.
Any changes to the 4-20mA scale require the Modbus communication interface.
1. Device Address
The device address in register 0 is also called slave ID. Valid device addresses are 1-247
decimal. Factory default is 240. Slave ID 0 is reserved for broadcast mode and will not supported
at this time. **Note: All smart sensors have a default setup at the startup window time. The user
must wait at least 10 seconds at the power up time before starting Modbus communication for slave
ID’s other than 240, or multiple drops connections.
2. Baud Rate
The Baud Rate in register 1 is selectable via the Modbus Communications Interface. The
selectable baud rates are 9600, 19.2k or 38.4K bits per second. Value 9 is 9600, 19 is 19.2K and
38 is 38.4K. The default baud rate is 19.2K.
Baud Rate Value Access
9600 9 Read/Write
19,200 19 Read/Write
38,400 38 Read/Write
3. Data Format
The Data Format in register 2 is selectable via the Modbus Communications Interface. The
selectable data formats are as follows. The default value is 0 that means 8-N-1 format.
2021-5-12 P a g e 3 | 18
Sensorex Smart Sensor Modbus User Instruction Rev. 1.0
8 Even 1 8-E-1 1
8 Odd 1 8-O-1 2
8 None 2 8-N-2 3
Important note: The default communication setup Slave ID=240, Baud rate 19.2K bit/second, 8
data bits, no parity and one stop bit. In case the configuration set by user is forgotten and
communication is not working, your smart sensor has a startup window to rebuild the
communication with the default setup upon power up.
2021-5-12 P a g e 4 | 18
Sensorex Smart Sensor Modbus User Instruction Rev. 1.0
2021-5-12 P a g e 5 | 18
Sensorex Smart Sensor Modbus User Instruction Rev. 1.0
6 CRC16_L 10
7 CRC16_H 31
2021-5-12 P a g e 6 | 18
Sensorex Smart Sensor Modbus User Instruction Rev. 1.0
2021-5-12 P a g e 7 | 18
Sensorex Smart Sensor Modbus User Instruction Rev. 1.0
2021-5-12 P a g e 8 | 18
Sensorex Smart Sensor Modbus User Instruction Rev. 1.0
6 CRC16_L 74
7 CRC16_H FA
The float point is 32 bit IEEE751 standard that reads out with high bytes first. See example 2.
2021-5-12 P a g e 9 | 18
Sensorex Smart Sensor Modbus User Instruction Rev. 1.0
7 CRC16_L 83
8 CRC16_H 31
2021-5-12 P a g e 10 | 18
Sensorex Smart Sensor Modbus User Instruction Rev. 1.0
1. Put probe into buffer A. read the probe raw measurement of register 86-87 see Example 6.
When the reading value is stable, write down the reference value and measurement value.
Such as reference buffer is 4.0pH, measured value is 3.86pH.
2. Rinse the probe and put probe into buffer B. Read the probe raw measurement of register
86-87. When the reading value is stable, write down the reference value and
measurement value, such as reference buffer is 10.0pH, measured value is 9.56pH.
3. Write value 4.0 to register 90-91. Write 3.86 to register 92-93. Write 10.0 to register 94-95.
Write value 9.56 to register 96-97. Write 12 bytes ASCII string into register 98-103.
Remember to unlock write protection for every write command. There is no combined
write for all calibration data, in another word, one-write command for one float point.
Because the sensor will do the copy processing for every calibration data storage. See
unlock command and example 4.
Example 7. Write 12 bytes of Calibration Time Digits into register 98-103.
Command: write '201903221130' into register 98
byte index byte description Example(Hex)
0 Slave ID F0
1 Function Code 10
2 Reg_Addr_H 0
3 Reg_Addr_L 62
4 Number of regester_H 0
5 Number of regester_L 6
6 Byte Count C
7 byte0 32
8 byte1 31
9 byte2 31
10 byte3 39
11 byte4 30
12 byte5 33
13 byte6 32
14 byte7 32
15 byte8 31
16 byte9 31
17 byte10 33
18 byte11 30
19 CRC16_L B2
20 CRC16_H 8D
2021-5-12 P a g e 11 | 18
Sensorex Smart Sensor Modbus User Instruction Rev. 1.0
“cp2-3-0-4” – Contact conductivity sensor with second design change, firmware for
Sensorex sensors. Major reversion 0 and minor reversion 4.
“ph-3-0-4” – pH sensor.
“cl-3-0-4” – Free Chlorine sensor.
“do-3-0-4” -– Dissolved oxygen sensor.
“to2-3-0-4” -– Toroidal conductivity sensor with second design change.
“orp-3-0-4” – ORP sensor.
Register 16-21. Model number is a 12 byte ASCII string indicating product model number
such as EM802-EC-MB2.
2021-5-12 P a g e 12 | 18
Sensorex Smart Sensor Modbus User Instruction Rev. 1.0
Register 22-27. It is a 12 byte ASCII string indicating manufacturing serial number such
as 2021012811.
Register 28-33. It is a space of 12 bytes ASCII reserved for user labeling the sensor.
The exception response message (ref. No. 4 above) has two fields that differentiate it from a
normal response:
Byte Modbus Range Referenced to Sensor
2021-5-12 P a g e 13 | 18
Sensorex Smart Sensor Modbus User Instruction Rev. 1.0
Exception Code Field: In a normal response, the Sensor returns data and status in the data
field, which was requested in the query from the master. In an exception response, the Sensor
returns an exception code in the data field, which describes the Sensor condition that caused the
exception. Below is a list of exception codes that are supported by the Sensorex Modbus:
Code Name Description
01 Illegal Function The function code received in the query is not an allowable action
for the Sensor.
02 Illegal Data Address The data address received in the query is not allowable address
for the Sensor.
03 Illegal Data Value A value contained in the query data field is not an allowable value
for the Sensor.
04 Slave Device Failure An unrecoverable error occurred while the Sensor was
attempting to perform the requested action.
05 Acknowledge Sensor has accepted the request and is processing it, but a
long duration of time will be required to do so. This response is
returned to prevent a timeout error from occurring in the master.
06 Device Busy The Sensor is engaged in processing a long-duration program
command. The master should retransmit the message later
when the slave is free.
17. Soft Reset Sensor
Sensorex Modbus has a soft reset command that resets (reboots) the sensor without cycling the
power. That is convenient in configuration for the multi-drop application. The following is the
command detail. The sub-command is 89(0x59) and the password is ASCII “RX” that is 0x5258 in
hex.
Command Soft Reset sensor
byte index byte description Example (Hex)
0 Slave ID F0
1 Function Code 6
2 Register H 0
3 Register L 59
4 Password _H 52
5 Password _L 58
6 CRC16_L 70
7 CRC16_H 62
2021-5-12 P a g e 14 | 18
Sensorex Smart Sensor Modbus User Instruction Rev. 1.0
The return response is the same as the message the master sent. Then slave sensor will take a
few seconds for reboot.
This register List is also a memory map for sensor to access the manufacturing calibration
parameters when processing the measurement data. Some of them are for manufacture
calibration mode. Many important factor data is using for calculation on the run time. Please take
precaution when writing into register. Any improper write will cause sensor malfunction.
Register
Address Register Name Format count Bytes ACCESS
0 modbus_address uint8 1 2 Read/write
1 baud_rate uint8 1 2 Read/write
2 serial_format uint8 1 2 Read/write Write/read
3 probe_value float 2 4 Read only
5 probe_temp_c grade float 2 4 Read only
7 probe_alternate_value float 2 4 Read only Read
9 loop_current_ma float 2 4 Read only
11 probe_value_min float 2 4 Read/write
13 probe_value_max float 2 4 Read/write
15 probe range uint16 1 2 Read only
16 model_number char12 6 12 Read only
22 serial_number char12 6 12 Read only
28 user_label char12 6 12 Read/write
34 firmware_version char12 6 12 Read only
40 manufacture_date char12 6 12 Read only
46 temperature_coefficient float 2 4 Read/Write
48 pressure_torr uint16 1 2 Read/write
50 salinity_ppm uint16 1 2 Read
51 reed_switch_active uint16 1 2 Read
52 operating_mode uint16 1 2 Read/write
53 override_mode uint16 1 2 Read
54 override_value float 2 4 Read
56 probe_duty_cycle_c2 float 2 4 Read
58 probe_duty_cycle_c1 float 2 4 Read
60 probe_duty_cycle_c0 float 2 4 Read
62 probe_temp_c2 float 2 4 Read
64 probe_temp_c1 float 2 4 Read
66 probe_temp_c0 float 2 4 Read/write
68 probe_value_c2 float 2 4 Read
70 probe_value_c1 float 2 4 Read
72 probe_value_c0 float 2 4 Read
2021-5-12 P a g e 15 | 18
Sensorex Smart Sensor Modbus User Instruction Rev. 1.0
2021-5-12 P a g e 16 | 18
Sensorex Smart Sensor Modbus User Instruction Rev. 1.0
2021-5-12 P a g e 17 | 18