Modbus resources
- Last UpdatedJun 25, 2026
- 2 minute read
Modbus resources are used to specify the register mappings for different programmable logic controllers (PLCs). When the resource is used in the Modbus Reader module, all listed tags are retrieved. Additional tags can be added to the module. A JSON file is used to define these mappings. Any properties in addition to the default tag properties later described, are treated as custom metadata and will be added to the messages.
Code example: Modbus resource
{
"name": "PLC1",
"unitId": "1",
"tags": [
{
"id": "tag1",
"modbusDataType": "Int",
"modbusFunction": "ReadHoldingRegisters",
"address": "0001"
},
{
"id": "tag2",
"unitId": "2",
"modbusDataType": "Byte",
"modbusFunction": "ReadDiscreteInputs",
"address": "001B"
}
]
}
Note: The address and unitId must be specified in hex. For example, decimal '27' would be '1B' in hex producing '001B' in the resource file.
How to reference Modbus resources
A Modbus device (PLC) is specified as a JSON object that must have at least a name
and one tag in the tags list. Optionally, the unitId can be specified if something
other than the default value of 1 is needed.
Custom metadata can be added to every object in the resource file, which then becomes
part of the outgoing message.
A tag (register) is defined by using the following parameters:
-
id: Unique name of the tag, will be included in the message.
-
name: Optional name of the tag, will be included in the message. If not specified, 'name' will be set to 'id'.
-
modbusDataType: The type of data to read, could be one of: `Byte`, Int, UInt, String, Short, UShort, Float and Double. This setting will affect the number of bytes to read and how they should be interpreted by the module.
-
modbusFunction: Defines what function code to use (address space), could be one of ReadDiscreteInputs, ReadHoldingRegisters, ReadCoils and ReadInputRegisters.
-
address: The starting address of the data in hex. (decimal address 27 would be 1B in hex resulting in 001B which is expected in the resource file).
-
length: Integer (>=1), only used with String types to specify the number of characters to read.
-
unitId: An optional setting for overriding the global unitId for this tag/register. Must be specified in hex.