Modbus connector Basic & Scale
The Modbus connectors of ConnectMQ Edge read energy meters, drives, PLCs and RS-485 sensors over Modbus TCP, UDP, RTU or ASCII, on a COM port or through a serial-to-Ethernet gateway. Every value is published to your ConnectMQ broker as an ISA-95 topic with value, quality, unit and timestamp.
Drivers and limits
ConnectMQ Edge has three Modbus drivers. They share the same engine; they differ in default transport and limits.
| Driver | Use it for | Max channels | Max devices per channel | Default transport / framing |
|---|---|---|---|---|
ModbusTcp (template Modbus TCP) | Devices on Ethernet | 1024 | 8192 | TCP / MBAP |
ModbusRtuSerial (template Modbus RTU) | RS-232/RS-485 devices | 1024 | 255 | Serial / RTU |
ModbusAsciiSerial | ASCII serial devices | 100 | 247 | Serial / ASCII |
Supported function codes: FC01–04 for reading, FC05/06/15/16 for writing and FC22 (mask write) for writing a bit inside a register.
Limits are per driver, not per project. How many values you can send to the cloud depends on your plan: see Plans & broker limits and pricing.
Transport and framing
Transport and Framing are independent, so all common setups are covered:
| Transport | Framing | Use |
|---|---|---|
Tcp | Mbap | Standard Modbus TCP (port 502) |
Udp | Mbap | Modbus UDP |
Serial | Rtu / Ascii | COM port (RS-232/RS-485) on the Edge PC |
Tcp / Udp | Rtu / Ascii | Ethernet encapsulation: RTU/ASCII frames to a serial-to-Ethernet gateway |
Prepare the device
Modbus TCP
- Find the device IP address, the port (usually
502) and its Unit ID (slave ID, often1). Gateways in front of several devices use one Unit ID per device. - Get the register map from the device manual: which value is at which address, its data type (16/32-bit, float) and its scaling.
- Enable Modbus TCP on the device if it is optional (many drives and meters have a "Modbus TCP server" setting).
- Check that the Edge PC reaches the device:
Test-NetConnection 192.168.1.10 -Port 502in PowerShell.
Modbus RTU / ASCII (RS-485)
- Connect the bus to the Edge PC with a USB-RS485 adapter, or use a serial-to-Ethernet gateway. In Device Manager › Ports (COM & LPT) note the COM port.
- Take the line settings from the devices: baud rate, parity, data bits, stop bits. All devices on the bus need the same settings and different Unit IDs.
- Wire A/B (D+/D-) and a common ground, with a 120 Ω terminator at both ends of long lines. If nothing answers, swap A and B.
- Only one program can open a COM port: close other Modbus tools first.
Add the connector in ConnectMQ Edge
Add a channel from the template
In the ConnectMQ Edge desktop app open Connectors in the left menu, click + Add channel and pick the Modbus TCP template (or Modbus RTU for RS-485 devices). The channel is added with sample addresses. There is no separate ASCII template: for Modbus ASCII devices start from Modbus RTU and set "Driver": "ModbusAsciiSerial".
Enter the connection
For Modbus TCP set Host and Port in the channel settings. Devices with their own IP address get their own Host in the device settings. For RS-485 set the Serial port (PortName, BaudRate, Parity…), or "Transport": "Tcp" with the gateway's IP address and port.
Add one device per Unit ID
Each device is one Unit ID (UnitId). Set ByteOrder if the device stores 32-bit values with swapped words.
Add your tags
List the registers from the manual as tags: a name, an address such as 40001, the DataType, and optionally Unit, Scale and Deadband. Neighbouring registers are combined into one request automatically.
Validate and save
Click Validate project, then press Save and apply. The channel starts right away without restarting the service. Add as many channels as you need, including several of the same type.
Check the values
On Overview the devices show Reading data under Field devices; problems appear in the Last problem column. Live values are on Local OPC UA Server › Live tag values, details in Windows Service Settings › Logs.
Settings reference
Channel settings
| Setting | Default | Description |
|---|---|---|
Transport | depends on driver | Tcp, Udp, Serial |
Framing | depends on driver | Mbap, Rtu, Ascii |
Host / Port | — / 502 | Device or gateway address; can be overridden per device |
OneSocketPerChannel | false | true: all devices in the channel share one socket (it reconnects when the target IP changes). A serial port always has one connection |
ConnectTimeoutMs | 3000 | Connection timeout in ms |
RequestTimeoutMs | 3000 | Request/response timeout in ms |
Retries | 2 | Extra attempts after a timeout |
InterFrameDelayMs | 0 | Pause before every request. Serial RTU adds the 3.5-character silence automatically |
DemoteAfterFailures | 3 | After this many failures in a row the device is marked offline |
DemoteForMs | 10000 | How long an offline device is skipped |
InterRequestDelayMs | 0 | Pause between scans |
Serial.PortName | COM1 | Serial port |
Serial.BaudRate | 9600 | |
Serial.DataBits | 8 | |
Serial.Parity | None | None, Odd, Even, Mark, Space |
Serial.StopBits | One | One, OnePointFive, Two |
Serial.Handshake | None | None, XOnXOff, RequestToSend, RequestToSendXOnXOff |
Serial.RtsEnable / Serial.DtrEnable | false |
Device settings
| Setting | Default | Description |
|---|---|---|
UnitId | 1 | Slave / Unit ID (0 = broadcast; on a serial line only for writes) |
Host / Port | from channel | Device-specific IP/port (with Modbus TCP every device can have its own IP) |
OneBasedAddressing | true | true: addresses are one-based (40001 / hr:1 → protocol address 0). false: zero-based (40001 → 1, hr:0 → 0) |
ZeroBasedBits | true | Register bit numbers start at 0 (true) or 1 |
BitOrderMsbFirst | false | true: bit 0 is the most significant bit |
ByteOrder | ABCD | 32-bit order: ABCD (big endian), CDAB (word swap), BADC (byte swap), DCBA (little endian). For 64-bit values the 4-letter form reverses all words |
ByteOrder64 | ByteOrder | Separate 64-bit order (8 letters): ABCDEFGH, GHEFCDAB, BADCFEHG, HGFEDCBA, CDABGHEF, EFGHABCD |
StringLowByteFirst | false | Byte order inside a register for strings (false = high byte first) |
MaxCoils | 2000 | Max bits per coil (FC01) request |
MaxDiscreteInputs | 2000 | Block size for discrete inputs (FC02) |
MaxHoldingRegisters | 120 | Block size for holding registers (FC03, protocol maximum 125) |
MaxInputRegisters | 120 | Block size for input registers (FC04) |
MaxRegisterGap | 8 | Tags separated by up to this many unused registers are still read in one request |
MaxBitGap | 64 | The same rule for bit areas |
UseMultipleCoilWrite | false | Use FC15 instead of FC05 for a single coil |
UseMultipleRegisterWrite | false | Use FC16 instead of FC06 for a single register |
UseMaskWrite | true | Use FC22 to write a register bit. If the device answers "illegal function", Edge switches to read-modify-write (FC03 + FC06/16). Set false for devices that never answer FC22 |
The device also has ScanRateMs and an Isa95 block (Area, Line, Cell).
Tag settings
| Setting | Description |
|---|---|
Address | See address syntax |
DataType | See data types. Auto: coil / discrete input / register bit → Boolean, register → UInt16 |
Length | Number of characters for String (max 250) |
Writable | Only coils and holding registers can be written |
Settings.ByteOrder | Byte order for this tag only |
Settings.UnitId | A different Unit ID for this tag (another slave behind a gateway) |
Unit, Scale, Offset, Deadband | Unit, value = raw × Scale + Offset, minimum change before publishing |
Address syntax
| Format | Example | Area |
|---|---|---|
| Modicon, 5 digits | 00001, 10001, 30001, 40001 | 0x coil, 1x discrete input, 3x input register, 4x holding register (1–9999) |
| Modicon, 6 digits | 000001, 100001, 300001, 400001 | Same areas, 1–65536 |
| Explicit | co:1, di:1, ir:1, hr:1 (also hr1, 4x1, 3x1, 0x1, 1x1) | |
| Register bit | 40001.5, hr:10.3 | A bit inside a holding or input register (Boolean) |
Addresses are converted to protocol addresses according to OneBasedAddressing. Multi-register types (32/64-bit, strings) use consecutive registers starting at the given address, so a Float32 at 40001 uses 40001 and 40002 and the next tag starts at 40003.
Data types
| Type | Registers | Notes |
|---|---|---|
Boolean | bit | Coil, discrete input or register bit |
Int8, UInt8 | 1 | Low byte of the register |
Int16, UInt16 | 1 | |
Bcd16 | 1 | 0–9999 |
Int32, UInt32, Float32 | 2 | ByteOrder applies |
Bcd32 | 2 | 0–99999999, word order applies |
Int64, UInt64, Float64 | 4 | ByteOrder64 (or ByteOrder) applies |
String | Length ÷ 2, rounded up | Latin-1; trailing spaces and NUL are trimmed |
Example
An energy meter on Modbus TCP. The project's ISA-95 levels are connectmq / site1 / production / line1, and the device sets Cell: panel1.
| Name | Address | DataType | Unit | Notes |
|---|---|---|---|---|
Voltage | 40001 | Float32 | V | |
Current | 40003 | Float32 | A | |
Energy | 400101 | UInt64 | kWh | Scale 0.001 |
Alarm | 40010.3 | Boolean | Bit 3 of register 40010 | |
Setpoint | 40020 | Int16 | Writable |
{
"Name": "EnergyMeters",
"Driver": "ModbusTcp",
"Settings": { "Host": "192.168.1.10", "Port": 502, "RequestTimeoutMs": 2000, "Retries": 1 },
"Devices": [
{
"Name": "MainPanel",
"ScanRateMs": 1000,
"Isa95": { "Cell": "panel1" },
"Settings": { "UnitId": 1, "ByteOrder": "CDAB" },
"Tags": [
{ "Name": "Voltage", "Address": "40001", "DataType": "Float32", "Unit": "V" },
{ "Name": "Current", "Address": "40003", "DataType": "Float32", "Unit": "A" },
{ "Name": "Energy", "Address": "400101", "DataType": "UInt64", "Scale": 0.001, "Unit": "kWh" },
{ "Name": "Alarm", "Address": "40010.3", "DataType": "Boolean" },
{ "Name": "Setpoint", "Address": "40020", "DataType": "Int16", "Writable": true }
]
}
]
}RS-485 devices behind a serial-to-Ethernet gateway (RTU over TCP), one device per Unit ID:
{
"Name": "RS485Line",
"Driver": "ModbusRtuSerial",
"Settings": { "Transport": "Tcp", "Host": "192.168.1.50", "Port": 4001, "OneSocketPerChannel": true },
"Devices": [
{ "Name": "Temp1", "Settings": { "UnitId": 1 }, "Tags": [ { "Name": "T", "Address": "30001", "DataType": "Int16", "Scale": 0.1, "Unit": "°C" } ] },
{ "Name": "Temp2", "Settings": { "UnitId": 2 }, "Tags": [ { "Name": "T", "Address": "30001", "DataType": "Int16", "Scale": 0.1, "Unit": "°C" } ] }
]
}A device directly on a COM port uses "Settings": { "Serial": { "PortName": "COM3", "BaudRate": 19200, "Parity": "Even", "DataBits": 7 } }.
The Voltage tag of the meter arrives in ConnectMQ on the topic:
connectmq/site1/production/line1/panel1/MainPanel/Voltagewith this payload:
{
"timestamp": "2026-10-21T14:29:00.123Z",
"value": 230.4,
"quality": "good",
"unit": "V",
"dataType": "Float32",
"tag": "Voltage",
"device": "MainPanel",
"channel": "EnergyMeters"
}See Topics and payloads for topic rules and quality values.
Write values to the device
Coils and holding registers with "Writable": true can be written:
- From the cloud: turn on Allow writes from the cloud in Cloud Settings, then publish
{"value": 12.5}(or just12.5) to the tag topic plus/set, for exampleconnectmq/site1/production/line1/panel1/MainPanel/Setpoint/set. - Locally: write the tag from an OPC UA client on the Edge local OPC UA server.
Coils use FC05 (or FC15), registers FC06 (or FC16), register bits FC22. Scale and Offset are reversed before writing.
Troubleshooting
| Symptom | Cause and fix |
|---|---|
| Floats look wrong (for example 1.2e-38 instead of 230.5) | Wrong word order. Switch ByteOrder between ABCD and CDAB; most meters use one of these. Check that 32-bit values span two registers. |
| Every value is off by one address | The manual uses zero-based addresses. Set "OneBasedAddressing": false on the device. |
Tags in one block are bad, connection stays up | Modbus exception (for example illegal data address). Check the addresses against the register map; lower MaxRegisterGap or MaxHoldingRegisters if the device rejects reads across unused registers. |
Timeout, device offline (bad_comm_failure) | Wrong IP/port/Unit ID, or no route. Test with Test-NetConnection. On RS-485 check baud rate, parity, A/B wiring and termination. |
| Serial port cannot be opened | Another program has the COM port open, or the port name is wrong. Close other tools and check Device Manager. |
| Slow or noisy RS-485 line | Raise RequestTimeoutMs (for example 2000) and Retries. |
| Writing a register bit fails | The device does not answer FC22. Set "UseMaskWrite": false. |