1. Introduction
The Modbus connector extracts values from Modbus devices and forwards the data to gRPC_kafka. Configuration is JSON‑based, enabling clear, repeatable deployments for both Modbus TCP and RTU environments.Key Features
- Unified TCP & RTU support – switch protocols per tag without changing code.
- Flexible polling triggers – send data when registers change, at fixed intervals, or when values shift by a percentage.
- Batch grouping by request ID – reduce bus chatter by bundling registers into shared requests.
- Comprehensive logging – customizable log file location, size rotation, and log levels for easy troubleshooting.
- Byte‑order & data‑type handling – interpret register values correctly with configurable endianness and type definitions.
2. Configuration
The Modbus connector is configured through a JSON file composed of alogSettings object and a tagConfiguration array. Each element of the array defines one register to poll and forward to the gRPC pipeline.
logSettings
| Field | Type | Description |
|---|---|---|
logFilePath | string | Path template for log files (the % is replaced with the device ID) |
logFileMaxMBSize | number | Maximum size per log file in MB before rotation |
logFileMaxFiles | number | Number of rotated files to keep |
logLevel | string | Logging level (trace, debug, info, etc.) |
tagConfiguration entries
Each entry describes one Modbus register to read.
Common fields
| Field | Type | Description |
|---|---|---|
deviceModel | string | Device model identifier used to locate register metadata |
protocol | string | Communication protocol: modbus_tcp or modbus_rtu |
dataPoint | string | Register address; may include an optional bit offset (32-0 for bit 0 at address 33) |
description | string | Human‑readable description of the register |
unit | string | Unit of measurement for the value |
triggerType | string | When to send data: changed, cyclic-N (N seconds), or percentage-N (N %) |
commParams | object | Protocol-specific communication parameters (see below) |
Note on dataPoint: The connector strips any text before the final / in the dataPoint value and uses only the number portion for the register address. This means prefixes (e.g., hr) are optional and serve only as human-readable hints; the register type is taken from commParams.registerType. It is useful to distinguish from modbus registers having the same addresses but on different registerType.
commParams for both TCP and RTU
| Field | Type | Description |
|---|---|---|
modbusServerID | number | Slave ID on the Modbus network (1‑247) |
numberOfRetries | number | Retry attempts before marking a request failed |
timeout | number | Response timeout in milliseconds |
requestID | number | Identifier used to group registers into a single Modbus request |
type | string | Data type of the register (e.g. s16, u32, float32) |
bytesOrder | string | Endianness / register order: ABCD, BADC, DCBA, CDAB |
cyclicPeriod | number | Interval for polling the register in milliseconds |
registerType | string | Modbus register class: holdingregisters, inputregisters, coils, or discreteinputs |
Additional commParams for modbus_rtu
| Field | Type | Description |
|---|---|---|
serialParity | string | Parity bit (none, even, odd, space, or mark) |
serialDataBits | number | Data bits (5–8) |
serialStopBits | number | Stop bits (1–3) |
serialBaudRate | number | Baud rate in bits/s (e.g. 9600, 19200) |
Example configurations
Modbus TCP
A bit offset can be appended with a -. The number after - selects the bit (0‑based) within the addressed register. Example configurations from the repository show usage such as “dataPoint”: “45-3”, meaning bit 3 of register 45:
Modbus RTU
3. Message format sent to Nexalis Cloud
4. Running the Connector
The Modbus connector is launched automatically by the Nexalis Agent.No manual execution is required under normal circumstances. For debugging purposes only, you can start it manually without using the Nexalis Agent launcher, you need to be in the directory of the executable “modbus_connector” and require four items:
- siteName: custom name of site where the data source is located
- deviceID: custom unique identification of the data source (OPC UA server)
- communicationAddress: IP address and port being used by the outstation.
- deviceModel: Json file that contains the OPC UA configurations (node definition, authentication, etc.).
5. Modbus data type
This section provides a detailed explanation of the possible configurable data types for the Nexalis agent Modbus connector. These types determine how data is structured, interpreted, and transmitted between a Modbus server and the Nexalis agent.-
Signed Integer Types
- s8: 8-bit signed integer (-128 to 127).
- s16: 16-bit signed integer (-32,768 to 32,767).
- s32: 32-bit signed integer (-2,147,483,648 to 2,147,483,647).
- s64: 64-bit signed integer (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807).
-
Unsigned Integer Types
- u8: 8-bit unsigned integer (0 to 255).
- u16: 16-bit unsigned integer (0 to 65,535).
- u32: 32-bit unsigned integer (0 to 4,294,967,295).
- u64: 64-bit unsigned integer (0 to 18,446,744,073,709,551,615).
-
Floating-Point Types
- float16: 16-bit floating-point number, IEEE 754 half precision (one registers).
- float32: 32-bit single-precision floating-point number, IEEE 754 single precision (two registers).
- float64: 64-bit double-precision floating-point number, IEEE 754 double precision (four registers).
-
String Types
- string-N: N-byte fixed-length string (use “A” or “B” as byteorder to skip most or least significant bytes). For example, string-4.
- utf8-N: N-byte UTF-8 encoded string (use A or B as byteorder to skip most or least significant bytes). For example, utf8-4.
- ascii-N: N-byte ASCII string (use A or B as byteorder to skip most or least significant bytes). For example, ascii-4.
- binary-N: N-byte binary string (Base64 encoded) (use A or B as byteorder to skip most or least significant bytes). For example, binary-4.
-
Timestamp Types
- timestamp-uint32: uint32 timestamp in seconds converted into 64bit integer milliseconds.
- timestamp-uint64: uint64 timestamp in seconds converted into 64bit integer milliseconds.
- timestamp-uint64-ms: uint64 timestamp in milliseconds converted into 64bit integer milliseconds.
- timestamp-float64: float64 timestamp in seconds converted into 64bit integer milliseconds.
- timestamp-float64-ms: float64 timestamp in millisecond converted into 64bit integer milliseconds.
- timestamp-ntp: ntp style timestamp 32 bit second and 32 bit fractional seconds converted into 64bit integer milliseconds
-
Bit Types
- bit: Single bit Boolean
- [Address]-N: Boolean extraction from a register. For example, 45-0 (register 45, bit 0). 45-3 means we extract the fourth bit.
- bit-N: N bits extracted from a specific register, the bit offset can be specified with LSB0 in the dataPoint. For example, dataPoint: 45-5 (register 45, bit 5) and bit-3 (3 bits from 45-5)
6. Modbus general information
Modbus data model
Modbus servers store values on register addresses. A Modbus register address is a specific location within a Modbus-compatible device (such as a sensor, actuator, or controller) where data is stored and can be read or written. These addresses are used in Modbus communication to specify where the data should be accessed or modified. A Modbus register is characterized by 1) Register type 2) Register Address 3) Size 4) Access and 5) byte order. There are four primary types of Modbus registers, each serving a different purpose: Table 1. Modbus register types| Register Type | Address Range | Register size | Access | Use |
|---|---|---|---|---|
| Coil Registers | 00001–09999 | 1 bit (0 or 1) | Read/Writing | Binary output |
| Discrete Inputs | 10001–19999 | 1 bit (0 or 1) | Read only | Binary input |
| Holding Registers | 40001–49999 | 16 bits | Read/Writing | Analog output |
| Input Registers | 30001–39999 | 16 bits | Read only | Analog input |
| bytesOrder | Example Value | Byte Order Description |
|---|---|---|
| ”ABCD” | AE41 5652 | high byte first, high word first (big endian) |
| “CDAB” | 5652 AE41 | high byte first, low word first |
| ”ABDC” | 41AE 5256 | low byte first, high word first |
| ”DCBA” | 5256 41AE | low byte first, low word first (little endian) |