Modbus Node
x/modbus
component: v0.29.0+ A Modbus read/write component used to perform Modbus protocol read or write operations. Supports two communication protocols: TCP and RTU.
Additional extension library required: rulego-components-iot (opens new window)
# Configuration
Field | Type | Description | Default Value |
---|---|---|---|
server | string | Modbus server address (Format: <mode>://<host:port> or <mode>://<serial device> ) | tcp://127.0.0.1:502 |
cmd | string | Modbus command name, supported commands include:ReadCoils , ReadDiscreteInputs , ReadRegisters , WriteCoil , WriteRegisters , etc. | ReadCoils |
unitId | uint8 | Unit ID (Slave ID).Format: uint8, Example: 1 | 1 |
address | string | Register address, placeholder variables ${} are allowed. Format: uint16, Example: 16 | None |
quantity | string | Number of registers, placeholder variables ${} are allowed | None |
value | string | Register value, placeholder variables ${} are allowed. No need to provide for reading. If writing multiple values, separate them with commas. For example: 0x01,0x01 , true , 51,52 . | None |
regType | uint | Register type, options:0 - Holding Register(0x03)1 - Input Register(0x04) | None |
TcpConfig | TCP Configuration Parameters | ||
timeout | int64 | Request timeout in seconds | 5 |
certPath | string | Path to the certificate (required for TLS/SSL connections) | None |
keyPath | string | Path to the private key (required for TLS/SSL connections) | None |
caPath | string | Path to the CA certificate (required for TLS/SSL connections) | None |
RtuConfig | RTU Configuration Parameters | ||
speed | uint | Serial baud rate (RTU mode only) | 19200 |
dataBits | uint | Number of data bits (RTU mode only) | 8 |
parity | uint | Parity mode (RTU mode only), options:0 - None1 - Even2 - Odd | 0 |
stopBits | uint | Number of stop bits (RTU mode only) | 2 |
EncodingConfig | Encoding Configuration Parameters | ||
endianness | uint | Byte order of registers, options:1 - Big Endian2 - Little Endian | 1 |
wordOrder | uint | Word order for 32-bit registers, options:1 - High Word First2 - Low Word First | 1 |
# Command Description
Command Name | Command Description | Parameter Description |
---|---|---|
ReadCoils | Read coil statuses | address : Starting address of coilsquantity : Number of coils to read |
ReadCoil | Read a single coil status | address : Address of the coil |
ReadDiscreteInputs | Read discrete input statuses | address : Starting address of discrete inputsquantity : Number of inputs to read |
ReadDiscreteInput | Read a single discrete input status | address : Address of the discrete input |
ReadRegisters | Read registers | address : Starting address of registersquantity : Number of registers to readregType : Register type (e.g., Holding Register or Input Register) |
ReadRegister | Read a single register | address : Address of the registerregType : Register type |
ReadUint32s | Read unsigned 32-bit integers | address : Starting address of registersquantity : Number of registers to readregType : Register type |
ReadUint32 | Read a single unsigned 32-bit integer | address : Address of the registerregType : Register type |
ReadFloat32s | Read 32-bit floating-point numbers | address : Starting address of registersquantity : Number of registers to readregType : Register type |
ReadFloat32 | Read a single 32-bit floating-point number | address : Address of the registerregType : Register type |
ReadUint64s | Read unsigned 64-bit integers | address : Starting address of registersquantity : Number of registers to readregType : Register type |
ReadUint64 | Read a single unsigned 64-bit integer | address : Address of the registerregType : Register type |
ReadFloat64s | Read 64-bit floating-point numbers | address : Starting address of registersquantity : Number of registers to readregType : Register type |
ReadFloat64 | Read a single 64-bit floating-point number | address : Address of the registerregType : Register type |
ReadBytes | Read byte data | address : Starting address of registersquantity : Number of registers to readregType : Register type |
ReadRawBytes | Read raw byte data | address : Starting address of registersquantity : Number of registers to readregType : Register type |
WriteCoil | Write a single coil status | address : Address of the coilvalue : Value to write (boolean) |
WriteCoils | Write multiple coil statuses | address : Starting address of coilsvalue : Values to write (boolean array) |
WriteRegister | Write a single register | address : Address of the registervalue : Value to write (16-bit integer) |
WriteRegisters | Write multiple registers | address : Starting address of registersvalue : Values to write (16-bit integer array) |
WriteUint32 | Write a single unsigned 32-bit integer | address : Address of the registervalue : Value to write (32-bit integer) |
WriteUint32s | Write multiple unsigned 32-bit integers | address : Starting address of registersvalue : Values to write (32-bit integer array) |
WriteFloat32 | Write a single 32-bit floating-point number | address : Address of the registervalue : Value to write (floating-point number) |
WriteFloat32s | Write multiple 32-bit floating-point numbers | address : Starting address of registersvalue : Values to write (floating-point number array) |
WriteUint64 | Write a single unsigned 64-bit integer | address : Address of the registervalue : Value to write (64-bit integer) |
WriteUint64s | Write multiple unsigned 64-bit integers | address : Starting address of registersvalue : Values to write (64-bit integer array) |
WriteFloat64 | Write a single 64-bit floating-point number | address : Address of the registervalue : Value to write (floating-point number) |
WriteFloat64s | Write multiple 64-bit floating-point numbers | address : Starting address of registersvalue : Values to write (floating-point number array) |
WriteBytes | Write byte data | address : Starting address of registersvalue : Values to write (byte array) |
WriteRawBytes | Write raw byte data | address : Starting address of registersvalue : Values to write (byte array) |
# Relation Type
- Success: On successful execution, the message is sent to the
Success
chain. - Failure: On failed execution, the message is sent to the
Failure
chain.
# Execution Result
Write: Do not change the message payload value.
Read: Returns an array, where each element is an object containing the following fields:
- Field List
Field Name | Data Type | Description |
---|---|---|
unitId | int | Unit ID (Slave ID) |
type | string | Data type, e.g., "uint16" |
address | int | Address, indicating the storage location of the data |
value | int float bool []byte | Current value, representing the data content |
- Example Data(reading Modbus data format):
[
{
"unitId": 1,
"type": "uint16",
"address": 4,
"value": 0
},
{
"unitId": 1,
"type": "uint16",
"address": 5,
"value": 0
},
{
"unitId": 1,
"type": "uint16",
"address": 6,
"value": 0
},
{
"unitId": 1,
"type": "uint16",
"address": 7,
"value": 0
},
{
"unitId": 1,
"type": "uint16",
"address": 8,
"value": 0
},
{
"unitId": 1,
"type": "uint16",
"address": 9,
"value": 0
},
{
"unitId": 1,
"type": "uint16",
"address": 10,
"value": 0
},
{
"unitId": 1,
"type": "uint16",
"address": 11,
"value": 0
},
{
"unitId": 1,
"type": "uint16",
"address": 12,
"value": 0
},
{
"unitId": 1,
"type": "uint16",
"address": 13,
"value": 0
}
]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Edit this page on GitHub (opens new window)
Last Updated: 2025/03/06, 12:39:26