1. Home
  2. Docs
  3. SmartConfig2.1
  4. 4. Configuration Area
  5. 4.2 Input Ports
  6. 4.2.5 RS-485 (Modbus RTU)

4.2.5 RS-485 (Modbus RTU)

The SmartSampler2 supports integration of Modbus RTU-compatible sensors via the RS-485 interface. Configuration is done using the built-in GUI and flexible parsing rules to extract values from sensor responses.


๐Ÿ”Ž Overview

  • Protocol: Modbus RTU
  • Function codes: Supported via manual polling (currently fixed to 0x03 โ€“ Read Holding Registers)
  • Transport: RS-485, half-duplex
  • Live Reading: ON/OFF toggle for periodic polling of configured sensors
  • Multi-register support: Handles multi-variable sensors within one device
  • Custom parsing: Extract and decode values with flexible configuration strings

Configuration

Serial Configuration

  • Baudrate
    • Select the communication speed (bits per second).
    • Must match the baud rate of the connected device (e.g., 9600, 19200, 115200).
  • Configuration
    • Defines the serial frame format: data bits, parity, stop bits (e.g., 8N1 = 8 data bits, no parity, 1 stop bit).
    • Ensure this setting matches the external sensor/device.
  • Save
    • Stores the selected settings permanently in EEPROM.

โš™๏ธ RS-485 Sensor Configuration

The Sensor Configuration panel accepts a list of sensors defined in a structured, comma-separated format.

Format

sensor_name,address,register,label,bytes,scaling,offset,order

Parameters

  • sensor_name โ†’ Group name for logs (e.g., SensorName)
  • address โ†’ Modbus slave ID (decimal, e.g., 1)
  • register โ†’ Start register address (decimal or hex, e.g., 0 or 0x0000)
  • label โ†’ Variable name in the output (e.g., temp, do, do_percent)
  • bytes โ†’ Number of bytes to read (e.g., 4 for float32 = 2 registers)
  • scaling โ†’ Multiplier for raw value (e.g., 1.0, 0.01)
  • offset โ†’ Value added after scaling (e.g., 0)
  • order โ†’ Byte order for decoding (ABCD, DCBA, BADC, CDAB)

Example Entries

SensorName,1,0,temp,4,1.0,0,ABCD
SensorName,1,290,do,4,1.0,0,ABCD
SensorName,1,292,do_percent,4,1.0,0,ABCD

๐Ÿ’พ Save & Load

  • Save โ†’ Stores the current configuration.
  • Load โ†’ Loads a previously saved configuration file.

๐Ÿ“ก Live Reading

  • When Live Reading = ON, the SmartSampler polls all configured Modbus sensors in sequence.
  • Each request is built using the Device ID and Register Address.
  • Responses are decoded according to the configured byte order, scaling, and offset.
  • Results appear in the Live Reading panel with timestamps.

๐Ÿงช RS-485 Test Area

The Test tab is designed for diagnostics and manual communication with Modbus devices.

RS-485 Test

Single Request

  • Enter a one-line configuration string (same format as in the main panel):
SensorName,1,0x0100,temp,4,1.0,0,ABCD
  • Sends Function 0x03 to slave ID 1
  • Reads 2 registers (4 bytes)
  • Applies byte order, scaling, and offset
  • Displays both raw and interpreted results

Response Breakdown

When a Single Request is executed in the Test tab, the SmartSampler shows a detailed breakdown of the received Modbus response.

  • The raw byte buffer is displayed exactly as returned by the sensor.
  • All four possible byte orders (ABCD, DCBA, BADC, CDAB) are decoded and shown for comparison.
  • The configured offset and scaling values are applied in every case.
  • This helps you quickly determine if the selected byte order matches the sensor datasheet and expected values.
  • The Final Result highlights the value calculated using the current Single Request configuration (address, register, scaling, offset, order).

Example response to: Read 4 bytes at register 0x0100 from address 1

Raw buffer: 85 12 cd 41
order ABCD = 25.634
order DCBA = -0.000
order BADC = -202920224.000
order CDAB = 0.000
Raw float = 25.634
Final Result = temp: 25.63

This structured output allows you to verify:

  • That the sensor is returning valid data.
  • Which byte order produces meaningful values.
  • Whether the configured offset and scaling match expectations.

Debug Passthrough

  • Passthrough mode forwards Modbus traffic directly, without parsing.
  • Useful for:
    • Testing sensors with custom tools
    • Sniffing communication
    • Low-level troubleshooting

๐Ÿ” Notes

  • Register addresses can be given in decimal or hex (0x prefix).
  • Always confirm register map, byte order, scaling, and offset from the sensor datasheet.
  • Function code is fixed to 0x03 (Read Holding Registers) in this release.

Message format:

[0xAA][LEN_H][LEN_L][CMD][SUB][DATA...][CHK][0x55]

with XOR checksum.

How can we help?