Skip to main content

Modbus Rules

Modbus Rules refers to a Modbus Command that NexusIM gateway act as a Modbus Master to acquire data from Modbus slave devices. One rule including assigned which interface for slave device, the slave device ID, the Modbus function code, (Read Holding Register) Start address, quantity count, data type…and other parameters.

Go to Sensor Data >> Devices and Rules >> Modbus Rules to view and configure Modbus commands list for slave devices.

Modbus Rule

  1. The order of Modbus rules.
  2. Specify the Device Name when adding a Modbus rule.
  3. Configure the interface to which the rule applies.
  4. Configure the Tag Name for the specified register value. Multiple tags can be separated with semicolons when reading continuous registers.
  5. Preview the current value collected from the southbound device under this rule communication.
  6. Configure the slave device ID.
  7. Configure the Modbus command function code, for example, 3 for Read Holding Registers.
  8. Configure the read starting address.
  9. Configure the read quantity.
  10. Configure the register data type.
  11. Specify the reporting center to which the collected data is reported. The number corresponds to Servers > Reporting Center > Server (1-5).
  12. Enable or disable the rule.
  13. Edit the added rule.
  14. Delete the added rule.
  15. Add a new rule.
  16. Export or import the rules configuration as a CSV template file. This is useful for configuration backups and batch operations.

Add a Modbus Rule​

This example reads a temperature and humidity sensor that uses the Modbus RTU protocol over an RS485 interface.

The following sensor datasheet example reads the temperature and humidity values from device address 0x01.

Inquiry frame (hexadecimal)

Address codeFunction codeStarting addressData lengthCheck code lowCheck code high
0x010x030x00 0x000x00 0x020xC40x0B

Response frame (hexadecimal)

For this example, the temperature is 30.5 C and the humidity is 48.6%RH.

Address codeFunction codeReturned byte countHumidity valueTemperature valueCheck code lowCheck code high
0x010x030x040x01 0xE60x01 0x310xDA0x7C

Temperature calculation: 0x0131 = 305; actual temperature = 305 / 10 = 30.5 C.

Humidity calculation: 0x01E6 = 486; actual humidity = 486 / 10 = 48.6%RH.

The temperature and humidity read command is 01 03 00 00 00 02 C4 0B.

The response data is 01 03 04 01 E6 01 31 DA 7C.

Because the raw values are divided by 10, configure the Modbus Rule on the NexusIM gateway as follows:

Add Modbus Rule

  1. Set the rule order.
  2. Specify the Device Name.
  3. Configure the interface. In this example, the temperature and humidity sensor is connected to the COM1-RS485 port.
  4. Configure the Tag Name for the register values. Multiple tags can be separated with semicolons when reading continuous registers.
  5. Configure the sensor Device ID.
  6. Configure the Modbus command function code. In this example, the function code is 3 for Read Holding Registers.
  7. Configure the read starting address.
  8. Configure the read quantity.
  9. Configure the register data type according to the sensor datasheet.
  10. Specify the reporting center to which the collected data is reported. The number corresponds to Servers > Reporting Center > Server (1-5).
  11. Configure the operator function: None, +, -, *, /, or Expression.
  12. Configure the operand.
  13. Configure the accuracy of the calculated value.
  14. Enable or disable SMS and email reporting. A report is sent to the specified phone number and email address when the value changes or falls outside the configured range.
  15. Enable or disable the rule.

The following example shows the event reporting configuration:

Event Reporting