Skip to content

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.

DriverUse it forMax channelsMax devices per channelDefault transport / framing
ModbusTcp (template Modbus TCP)Devices on Ethernet10248192TCP / MBAP
ModbusRtuSerial (template Modbus RTU)RS-232/RS-485 devices1024255Serial / RTU
ModbusAsciiSerialASCII serial devices100247Serial / 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:

TransportFramingUse
TcpMbapStandard Modbus TCP (port 502)
UdpMbapModbus UDP
SerialRtu / AsciiCOM port (RS-232/RS-485) on the Edge PC
Tcp / UdpRtu / AsciiEthernet 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, often 1). 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 502 in 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 ​

SettingDefaultDescription
Transportdepends on driverTcp, Udp, Serial
Framingdepends on driverMbap, Rtu, Ascii
Host / Port— / 502Device or gateway address; can be overridden per device
OneSocketPerChannelfalsetrue: all devices in the channel share one socket (it reconnects when the target IP changes). A serial port always has one connection
ConnectTimeoutMs3000Connection timeout in ms
RequestTimeoutMs3000Request/response timeout in ms
Retries2Extra attempts after a timeout
InterFrameDelayMs0Pause before every request. Serial RTU adds the 3.5-character silence automatically
DemoteAfterFailures3After this many failures in a row the device is marked offline
DemoteForMs10000How long an offline device is skipped
InterRequestDelayMs0Pause between scans
Serial.PortNameCOM1Serial port
Serial.BaudRate9600
Serial.DataBits8
Serial.ParityNoneNone, Odd, Even, Mark, Space
Serial.StopBitsOneOne, OnePointFive, Two
Serial.HandshakeNoneNone, XOnXOff, RequestToSend, RequestToSendXOnXOff
Serial.RtsEnable / Serial.DtrEnablefalse

Device settings ​

SettingDefaultDescription
UnitId1Slave / Unit ID (0 = broadcast; on a serial line only for writes)
Host / Portfrom channelDevice-specific IP/port (with Modbus TCP every device can have its own IP)
OneBasedAddressingtruetrue: addresses are one-based (40001 / hr:1 → protocol address 0). false: zero-based (40001 → 1, hr:0 → 0)
ZeroBasedBitstrueRegister bit numbers start at 0 (true) or 1
BitOrderMsbFirstfalsetrue: bit 0 is the most significant bit
ByteOrderABCD32-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
ByteOrder64ByteOrderSeparate 64-bit order (8 letters): ABCDEFGH, GHEFCDAB, BADCFEHG, HGFEDCBA, CDABGHEF, EFGHABCD
StringLowByteFirstfalseByte order inside a register for strings (false = high byte first)
MaxCoils2000Max bits per coil (FC01) request
MaxDiscreteInputs2000Block size for discrete inputs (FC02)
MaxHoldingRegisters120Block size for holding registers (FC03, protocol maximum 125)
MaxInputRegisters120Block size for input registers (FC04)
MaxRegisterGap8Tags separated by up to this many unused registers are still read in one request
MaxBitGap64The same rule for bit areas
UseMultipleCoilWritefalseUse FC15 instead of FC05 for a single coil
UseMultipleRegisterWritefalseUse FC16 instead of FC06 for a single register
UseMaskWritetrueUse 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 ​

SettingDescription
AddressSee address syntax
DataTypeSee data types. Auto: coil / discrete input / register bit → Boolean, register → UInt16
LengthNumber of characters for String (max 250)
WritableOnly coils and holding registers can be written
Settings.ByteOrderByte order for this tag only
Settings.UnitIdA different Unit ID for this tag (another slave behind a gateway)
Unit, Scale, Offset, DeadbandUnit, value = raw × Scale + Offset, minimum change before publishing

Address syntax ​

FormatExampleArea
Modicon, 5 digits00001, 10001, 30001, 400010x coil, 1x discrete input, 3x input register, 4x holding register (1–9999)
Modicon, 6 digits000001, 100001, 300001, 400001Same areas, 1–65536
Explicitco:1, di:1, ir:1, hr:1 (also hr1, 4x1, 3x1, 0x1, 1x1)
Register bit40001.5, hr:10.3A 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 ​

TypeRegistersNotes
BooleanbitCoil, discrete input or register bit
Int8, UInt81Low byte of the register
Int16, UInt161
Bcd1610–9999
Int32, UInt32, Float322ByteOrder applies
Bcd3220–99999999, word order applies
Int64, UInt64, Float644ByteOrder64 (or ByteOrder) applies
StringLength ÷ 2, rounded upLatin-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.

NameAddressDataTypeUnitNotes
Voltage40001Float32V
Current40003Float32A
Energy400101UInt64kWhScale 0.001
Alarm40010.3BooleanBit 3 of register 40010
Setpoint40020Int16Writable
json
{
  "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:

json
{
  "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:

text
connectmq/site1/production/line1/panel1/MainPanel/Voltage

with this payload:

json
{
  "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 just 12.5) to the tag topic plus /set, for example connectmq/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 ​

SymptomCause 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 addressThe manual uses zero-based addresses. Set "OneBasedAddressing": false on the device.
Tags in one block are bad, connection stays upModbus 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 openedAnother program has the COM port open, or the port name is wrong. Close other tools and check Device Manager.
Slow or noisy RS-485 lineRaise RequestTimeoutMs (for example 2000) and Retries.
Writing a register bit failsThe device does not answer FC22. Set "UseMaskWrite": false.

Fully managed MQTT broker for connected devices.