ReferenceDevice driversModbusRead task

Modbus read task

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

This task follows the standard task lifecycle.

Task configuration reference

Parameter Type Required Default Description
device string - Key of the Modbus server device
sample_rate number 10 Samples per second (Hz)
stream_rate number 5 Rate data is streamed to Synnax (Hz), must be ≤ sample_rate
channels array - 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.

Parameter Type Required Default Description
channel number - Synnax channel key
address number - Modbus register address (0-65535)
data_type string uint8 Data type: int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64, string
bytes_swapped boolean false Swap byte order within 16-bit words
words_swapped boolean false Swap word order for 32-bit+ values
string_length number 0 Register 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.

Parameter Type Required Default Description
channel number - Synnax channel key
address number - Modbus register address (0-65535)
data_type string uint8 Data type: int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64, string
bytes_swapped boolean false Swap byte order within 16-bit words
words_swapped boolean false Swap word order for 32-bit+ values
string_length number 0 Register 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).

Parameter Type Required Default Description
channel number - Synnax channel key
address number - 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).

Parameter Type Required Default Description
channel number - Synnax channel key
address number - 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