Skip to main content
Version: 2.0

Modbus Modbus Integration Guide

Communicate with PLCs, drives, meters, and sensors using MaestroHub's Modbus connector. This guide explains connection options, function authoring, pipeline usage, and advanced tuning for reliable operations.

Overview

With the Modbus connector you gain:

  • Support for TCP, RTU, and ASCII transports through a single configuration model
  • Reusable read/write functions covering coils, discrete inputs, holding registers, and input registers (FC01–FC06, FC15–FC16)
  • Rich data type supportraw, int16, uint16, int32, uint32, float32, int64, float64, bool, string, hex, and bits
  • Connection diagnostics including retries, timeouts, health checks, and automatic reconnection
  • Quick Add for bulk function creation via table entry or CSV import

Connection Configuration

Creating a Modbus Connection

Navigate to ConnectionsNew ConnectionModbus and configure the following settings. The form is organized into five tabs: Connection, Transport, Advanced, Functions, and Health.

1. Profile Information

FieldDefaultDescription
Profile NameA descriptive name for this connection profile (required, max 100 characters). Must be unique across all connections.
DescriptionOptional description for this Modbus connection

2. Connection Mode Settings

FieldDefaultDescription
Transport ModetcpModbus communication protocol: TCP (Ethernet), RTU (Serial Binary), or ASCII (Serial Text) — required
Unit ID1Modbus slave unit identifier (0–247)

3. TCP Transport Settings

(Only displayed when Transport Mode = TCP)

FieldDefaultDescription
IP Address:Portlocalhost:502Target device address in host:port format (standard Modbus TCP port is 502) — required
Connect Timeout (ms)3000Maximum time to wait for TCP connection (1,000–60,000 ms)
Enable TCP Keep-AlivetrueSend periodic keep-alive probes to detect connection failures
Keep Alive Period (ms)30000TCP keep-alive probe interval (1,000–1,800,000 ms)

4. Serial Transport Settings

(Only displayed when Transport Mode = RTU or ASCII)

FieldDefault (RTU)Default (ASCII)Description
Serial Device/dev/ttyUSB0/dev/ttyUSB0Serial port device path (e.g., /dev/ttyUSB0 on Linux, COM3 on Windows) — required
Baud Rate96009600Serial communication speed (1200/2400/4800/9600/19200/38400/57600/115200) — required
Data Bits87Number of data bits per character (7 or 8) — required
ParityN (None)E (Even)Error detection method (N=None / E=Even / O=Odd) — required
Stop Bits11Number of stop bits per character (1 or 2) — required
RS-485 ModefalsefalseEnable RS-485 transceiver mode (direction control)

5. Advanced Settings

The Advanced tab contains timeout, retry, and serial timing options:

5a. Timeout & Retry Configuration
FieldDefaultDescription
Request Timeout (ms)5000Maximum time to wait for a Modbus response (1,000–60,000 ms)
Idle Timeout (ms)10000Close connection after idle period (0–600,000 ms; 0 = never)
Retry Count2Number of retries on communication failure (0–10)
Retry Delay (ms)500Delay between retry attempts (100–60,000 ms)
5b. Serial Advanced Options

(Only displayed when Transport Mode = RTU or ASCII)

FieldDefaultDescription
Inter-Frame Delay (ms)0Silent interval between frames (0–10,000 ms; 0 = automatic per Modbus spec)
Inter-Character Delay (ms)0Delay between characters (0–1,000 ms; 0 = automatic)
Read Timeout (ms)0Low-level serial read timeout (0–10,000 ms; 0 = use default)

6. Health Check Configuration

Health check is always enabled for Modbus connections to ensure reliable device communication.

6a. Basic Health Check Settings
FieldDefaultDescription
Health Check MethodstatusHealth check type: Status (connection test only) or Read (perform an actual device read)
Retry Count1Number of retries for failed health checks (0–10)
Check Interval (ms)30000How often to perform health checks (1,000–86,400,000 ms; 1 s – 24 h)
6b. Read Method Fields

(Only displayed when Health Check Method = Read)

FieldDefaultDescription
Register TypeholdingType of register/coil to read: coil (FC01), discrete (FC02), holding (FC03), or input (FC04) — required
Address0Starting address to read (0–65,535) — required
Quantity1Number of registers/coils to read (1–2,000 for coils/discrete; 1–125 for registers) — required
Timeout (ms)3000Health check request timeout (1,000–60,000 ms) — required
Expected ValueOptional expected value for validation (0–65,535; leave empty to skip)

7. Connection Labels

FieldDefaultDescription
LabelsKey-value pairs to categorize and organize this Modbus connection (max 10 labels)

Example Labels

  • environment: production — Deployment environment
  • line: line-1 — Production line
  • equipment: plc — Equipment type
  • location: factory-floor — Physical location
Notes
  • Health Check is always enabled for Modbus connections to ensure reliable device communication.
  • Fields marked as "required" must be filled out before creating or saving the connection.
  • TCP and Serial settings are mutually exclusive based on the selected Transport Mode.
  • All timeout values are in milliseconds (ms).
  • The form includes real-time validation for all required fields.
  • ASCII mode defaults to 7 data bits and Even parity per the Modbus ASCII specification.

Function Builder

Creating Modbus Functions

After the connection is saved:

  1. Open the connection and navigate to the Functions tab
  2. Click New Function to open the function type selection dialog
  3. Choose a Read function (FC01–FC04) or a Write function (FC05–FC06, FC15–FC16)
  4. Fill in the Basic tab (name, description, labels) and the Configuration tab (addresses, values)
  5. Use the Test button to validate the function before saving

Each function has two configuration tabs:

  • Basic — Function name (required, max 100 characters, must be unique within the connection), optional description, and labels
  • Configuration — Function-specific parameters (address, quantity, values, data type)
Modbus Read Function Creation

Configure Modbus read operations with addressing, scaling, and output aliases

Modbus Write Function Creation

Author Modbus write functions with validation and safety checks

Quick Add: Bulk Function Creation

For scenarios where you need to create multiple Modbus functions at once, the Quick Add feature streamlines the process by allowing you to define many functions in a single operation.

When to Use Quick Add

  • Setting up a new Modbus connection with dozens of tags to monitor
  • Migrating existing tag lists from spreadsheets or documentation
  • Standardizing function creation across multiple similar devices
  • Quickly prototyping data collection without creating functions one by one

How to Use Quick Add

  1. Navigate to your Modbus connection in Connections
  2. Click Quick Add Functions button
  3. Choose your input method:
    • Table Entry: Add rows directly in the interface
    • CSV Import: Upload a CSV file with function definitions
Modbus Quick Add Interface

Quick Add Functions dialog with table entry and CSV import options

Table Columns

ColumnDescriptionExample
Function NameUnique name for the functionTemperature_Sensor_1
TypeModbus function codeRead Holding Registers (FC03)
AddressStarting register address40001
QuantityNumber of registers to read1
Data TypeValue interpretationfloat32, uint16, int32

Supported Function Types in Quick Add

  • Read Coils (FC01)
  • Read Discrete Inputs (FC02)
  • Read Holding Registers (FC03)
  • Read Input Registers (FC04)
  • Write Single Coil (FC05)
  • Write Single Register (FC06)
  • Write Multiple Coils (FC15)
  • Write Multiple Registers (FC16)

CSV Import Format

name,functionType,address,quantity,dataType
Temperature,read.holdingRegisters,40001,1,float32
Pressure,read.holdingRegisters,40003,1,uint16
FlowRate,read.inputRegisters,30001,2,float32
MotorStatus,read.coils,0,8,boolean

Validation Rules

  • Function names must be unique within the connection
  • Addresses must be in range 0–65,535
  • Read operations: quantity must be at least 1
  • Register limit: Total registers (quantity × data type register count) cannot exceed 125
  • Example: Reading 50 Float32 values requires 100 registers (50 × 2)

Best Practices

  • Use descriptive function names that reflect the physical sensor or control point
  • Group related functions together using consistent naming (e.g., Tank1_Temperature, Tank1_Pressure)
  • Validate your CSV file with a small batch before importing hundreds of functions
  • Consider data type register counts when planning bulk reads to stay within the 125 register limit

Data Types

Modbus register data can be interpreted using the following data types. The data type determines how raw 16-bit register values are converted into meaningful values.

Data TypeRegistersDescription
rawVariableNo conversion — returns array of raw 16-bit unsigned values
bool1Single bit/coil value (true/false)
int161Signed 16-bit integer (−32,768 to 32,767)
uint161Unsigned 16-bit integer (0 to 65,535)
int322Signed 32-bit integer
uint322Unsigned 32-bit integer
float322IEEE 754 single-precision floating point
int644Signed 64-bit integer
float644IEEE 754 double-precision floating point
stringVariableASCII text (2 characters per register, null-terminated)
hexVariableHexadecimal string representation (e.g., FF00 00A1)
bitsVariableBit array — 16 bits per register, MSB first
Register Counts

When reading multi-register data types, set the Quantity field to match the register count. For example, reading a float32 value requires a quantity of at least 2 registers, and float64 requires 4.

Read Coils (modbus.read.coils)

Purpose: Read status of discrete outputs (coils) using Function Code 01. Coils can be either ON (true) or OFF (false), allowing reading of multiple coil states in a single operation.

Configuration Fields

FieldTypeRequiredDefaultDescription
Starting AddressNumberYes0First coil address to read (0–65,535)
QuantityNumberYes1Number of coils to read in sequence (1–2,000)

Use Cases: Read relay states, check digital outputs, monitor coil status, bulk coil reading

Read Discrete Inputs (modbus.read.discreteInputs)

Purpose: Read status of discrete inputs using Function Code 02. These are typically read-only digital inputs from sensors, switches, or other devices.

Configuration Fields

FieldTypeRequiredDefaultDescription
Starting AddressNumberYes10000First discrete input address to read (0–65,535)
QuantityNumberYes8Number of discrete inputs to read (1–2,000)

Use Cases: Read sensor states, monitor switch positions, check digital inputs, bulk input scanning

Read Holding Registers (modbus.read.holdingRegisters)

Purpose: Read values from holding registers using Function Code 03. These are read-write 16-bit registers used for configuration, setpoints, and other operational data. This is the most common Modbus operation.

Configuration Fields

FieldTypeRequiredDefaultDescription
Starting AddressNumberYes40001First holding register address to read (0–65,535)
QuantityNumberYes10Number of registers to read (1–125)
Data TypeSelectNorawData type for value conversion (see Data Types table)

Use Cases: Read setpoints, get configuration values, monitor process variables, bulk data acquisition

Read Input Registers (modbus.read.inputRegisters)

Purpose: Read values from input registers using Function Code 04. These are typically read-only 16-bit registers containing measurement data, sensor readings, and status information.

Configuration Fields

FieldTypeRequiredDefaultDescription
Starting AddressNumberYes30001First input register address to read (0–65,535)
QuantityNumberYes4Number of registers to read (1–125)
Data TypeSelectNorawData type for value conversion (see Data Types table)

Use Cases: Read sensor values, get measurement data, monitor input signals, data logging operations

Write Single Coil (modbus.write.singleCoil)

Purpose: Write a single coil (discrete output) to ON or OFF state using Function Code 05. Used for controlling individual relays, digital outputs, or other binary actuators.

Configuration Fields

FieldTypeRequiredDefaultDescription
Coil AddressNumberYes0Address of the coil to write (0–65,535)
Coil ValueBooleanYestrueState to write to the coil (true = ON, false = OFF). Supports parameter templates.

Use Cases: Control relay states, set digital outputs, toggle equipment on/off, actuator control

Write Single Register (modbus.write.singleRegister)

Purpose: Write a single 16-bit value to a holding register using Function Code 06. Used for setting configuration values, setpoints, and other control parameters.

Configuration Fields

FieldTypeRequiredDefaultDescription
Register AddressNumberYes40001Address of the register to write (0–65,535)
Register ValueNumberYes016-bit value to write (0–65,535). Supports parameter templates.

Use Cases: Set configuration values, update setpoints, write control parameters, individual register updates

Write Multiple Coils (modbus.write.multipleCoils)

Purpose: Write multiple coils (discrete outputs) in a single operation using Function Code 15. Allows efficient bulk control of relays, digital outputs, or other binary devices.

Configuration Fields

FieldTypeRequiredDefaultDescription
Starting AddressNumberYes0First coil address to write (0–65,535)
Coil ValuesArrayYes[true, false]Array of boolean values for each coil (1–1,968 coils). Supports parameter templates.

Use Cases: Control multiple relays, set digital output patterns, bulk coil updates, equipment sequences

Write Multiple Registers (modbus.write.multipleRegisters)

Purpose: Write multiple 16-bit values to consecutive holding registers using Function Code 16. Allows efficient bulk updates of configuration data, setpoints, and control parameters.

Configuration Fields

FieldTypeRequiredDefaultDescription
Starting AddressNumberYes40001First register address to write (0–65,535)
Register ValuesArrayYes[0, 0]Array of 16-bit values for consecutive registers (1–123 registers, each 0–65,535). Supports parameter templates.

Use Cases: Bulk configuration updates, set multiple setpoints, write parameter blocks, data download operations

Using Parameters

Parameter placeholders ((parameterName)) can be used in write function fields (value, values, address) to make functions dynamic at execution time.

ConfigurationDescriptionExample
TypeValidate expected value typenumber, boolean, array, json
RequiredForce critical inputsRequired / Optional
Default ValueProvide safe fallbacksfalse, 250.0
DescriptionDocument purpose"Start/Stop command flag", "Setpoint in °C"
Modbus Function Parameters

Parameter configuration for Modbus scaling, coercion, and safety notes

Testing Functions

Every Modbus function can be tested before saving using the built-in Test dialog:

  1. Click the Test button in the function form
  2. The dialog shows an Execution Overview with the current configuration
  3. Override any parameter values in the Test Parameters section
  4. Click Execute Test to run the function against the live device
  5. View the result in the integrated JSON viewer, including execution duration and timestamp

The test dialog supports two modes:

  • Config-only Testing (create mode) — Tests the function configuration before saving
  • Function with Overrides (edit mode) — Tests the saved function with current form modifications

Pipeline Integration

Use the Modbus connection functions you define here as nodes inside the Pipeline Designer to synchronize PLC registers with the rest of your pipeline. Drag in the read or write node, bind parameters to upstream outputs or constants, and set retries or guard conditions before issuing commands.

For orchestration strategies that mix Modbus with other data sources, check the Connector Nodes page to see how these nodes slot into larger automation flows.

Modbus node in pipeline designer

Modbus read node with connection, function, and parameter bindings

Common Use Cases

Equipment Monitoring

Poll holding and input registers for temperature, flow, vibration, or energy metrics, then forward the data to historians or MQTT topics.

Control and Setpoint Management

Validate operator inputs and write them back to coils or registers to adjust production processes safely.

Data Normalization

Convert raw register values into engineering units, status codes, or structured JSON for downstream analytics using the built-in data type conversions (float32, int32, etc.).

Troubleshooting

Connection Issues

SymptomPossible CauseSolution
Connection timeoutDevice not reachableVerify network connectivity, IP address, and port. Standard Modbus TCP port is 502.
Invalid address formatMalformed host:portEnsure address is in host:port format (e.g., 192.168.1.10:502). Port must be 1–65,535.
Serial port errorWrong device pathVerify the serial device path (/dev/ttyUSB0, COM3, etc.) and that the port is not in use.
Unit ID mismatchWrong slave addressConfirm the Unit ID matches the device's configured slave address (0–247).
Health check failsDevice unresponsiveCheck the health check method and register settings. Try switching to Status method first.

Function Issues

SymptomPossible CauseSolution
Illegal function errorUnsupported function codeVerify the device supports the requested function code (e.g., not all devices support FC15/FC16).
Illegal data addressAddress out of rangeCheck that the starting address and quantity don't exceed the device's address space.
Incorrect valuesWrong data typeEnsure the data type matches the device's register format (e.g., float32 for IEEE 754 values).
Register limit exceededToo many registersReduce quantity — maximum is 125 for register reads and 2,000 for coil/discrete reads.
Timeout on writeDevice busyIncrease the request timeout or add retry logic. Check if the device is in a protected mode.
Testing Functions

Use the Test button in the Function Builder to validate your configuration before using it in pipelines. The test dialog lets you override parameters for one-off operations and displays the full response with execution timing.