ReferenceDriverModbusRead Task

Modbus Read Task

Learn how to acquire data from Modbus TCP devices with Synnax.

For the task lifecycle, see Task Basics.

Task Configuration Reference

ParameterTypeRequiredDefaultDescription
devicestringYes-Key of the Modbus server device
sample_ratenumberNo10Samples per second (Hz)
stream_ratenumberNo5Rate data is streamed to Synnax (Hz), must be ≤ sample_rate
channelsarrayYes-List of input channel configurations

Register Types Reference

Holding Register Input (holding_register)

Reads from 16-bit read/write registers (Function Code 03). Typically used for configuration parameters and analog outputs that can also be read back.

ParameterTypeRequiredDefaultDescription
channelnumberYes-Synnax channel key
addressnumberYes-Modbus register address (0-65535)
data_typestringNouint8Data type: int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64, string
bytes_swappedbooleanNofalseSwap byte order within 16-bit words
words_swappedbooleanNofalseSwap word order for 32-bit+ values
string_lengthnumberNo0Register count to read as a string. 0 reads a number

Data Type Sizes:

  • int8/uint8/int16/uint16: 1 register (2 bytes)
  • int32/uint32/float32: 2 registers (4 bytes)
  • int64/uint64/float64: 4 registers (8 bytes)

Input Register (input_register)

Reads from 16-bit read-only registers (Function Code 04). Typically used for analog sensor values like temperature, pressure, or flow.

ParameterTypeRequiredDefaultDescription
channelnumberYes-Synnax channel key
addressnumberYes-Modbus register address (0-65535)
data_typestringNouint8Data type: int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64, string
bytes_swappedbooleanNofalseSwap byte order within 16-bit words
words_swappedbooleanNofalseSwap word order for 32-bit+ values
string_lengthnumberNo0Register count to read as a string. 0 reads a number

Data Type Sizes:

  • int8/uint8/int16/uint16: 1 register (2 bytes)
  • int32/uint32/float32: 2 registers (4 bytes)
  • int64/uint64/float64: 4 registers (8 bytes)

Coil Input (coil)

Reads from 1-bit read/write coils (Function Code 01). Typically used for discrete output states that can be read back (e.g., relay states, valve positions).

ParameterTypeRequiredDefaultDescription
channelnumberYes-Synnax channel key
addressnumberYes-Modbus coil address (0-65535)

Data Type: Always boolean (0/1)

Discrete Input (discrete_input)

Reads from 1-bit read-only discrete inputs (Function Code 02). Typically used for binary sensor inputs (e.g., limit switches, proximity sensors).

ParameterTypeRequiredDefaultDescription
channelnumberYes-Synnax channel key
addressnumberYes-Modbus discrete input address (0-65535)

Data Type: Always boolean (0/1)

Important Rules

  • Software timing -> Samples are timestamped in software with ~100 µs precision, which degrades under heavy load.
  • Byte/word order -> Swap settings must match the server for multi-register data types.
  • Stream rate -> For sample rates under 50 Hz, set the stream rate equal to the sample rate. Above that, keep the stream rate under 50 Hz.

How-To