S7 Read
x/s7Read component: v0.37.0+ Batch reads point data from Siemens S7 series PLCs (S7-200SMART/300/400/1200/1500). Results are written back to msg.Data and forwarded via the Success chain.
Additional extension library required: rulego-components-iot (opens new window)
# Configuration
| Field | Type | Description | Default |
|---|---|---|---|
| server | string | PLC address in host:port format; the ISO-on-TCP default port is 102 | 127.0.0.1:102 |
| rack | int | Rack number | 0 |
| slot | int | CPU slot: S7-1200/1500/200SMART=1, S7-300/400=2 | 1 |
| timeout | int | Request timeout in seconds | 5 |
| points | []object | Default points table; points supplied via msg.Data take precedence when valid | [] |
# Point fields
| Field | Type | Description | Default |
|---|---|---|---|
| name | string | Point name (included in the output for downstream access) | None |
| addr | string | Siemens address (see syntax below); supports ${msg.xx} | None |
| type | string | Data type, see options below | None |
| scale | float | Optional scale factor; engineering value = raw value × scale + offset | - |
| offset | float | Optional offset | - |
| endian | string | Optional byte order | - |
# Point fields
addr field: Uses Siemens address syntax; supports ${msg.xx} template variables.
- DB area:
DB<n>.<DBX|DBB|DBW|DBD><offset>[.bit], e.g.DB1.DBD0,DB1.DBW2,DB1.DBX0.1 - M/I/Q areas: word/dword addresses such as
MW0,MD0,IW0,QW0; bit addresses such asM0.1
Data type options:
| Type | Bytes | Go output type | Description |
|---|---|---|---|
BOOL | 1 | bool | Boolean, use a bit address (e.g. DB1.DBX0.1, M0.1) |
BYTE | 1 | byte | Byte |
INT | 2 | int16 | Signed 16-bit integer (big-endian) |
WORD | 2 | uint16 | Unsigned 16-bit integer (big-endian) |
DINT | 4 | int32 | Signed 32-bit integer (big-endian) |
DWORD | 4 | uint32 | Unsigned 32-bit integer (big-endian) |
REAL | 4 | float32 | 32-bit float (big-endian) |
LREAL | 8 | float64 | 64-bit float (big-endian) |
STRING | 256 | string | S7 string (first byte = max length, second byte = actual length) |
# Output
Read results are reassigned to msg.Data and forwarded via the Success chain as an array:
| Field | Type | Description |
|---|---|---|
| name | string | Point name |
| value | any | Read value; its concrete type depends on the point type |
| timestamp | string | Read time (RFC3339) |
| error | string | Error message; empty on success (a single point failure does not affect other points) |
Example:
[
{"name":"temperature","value":25.6,"timestamp":"2026-07-23T10:00:00Z","error":""},
{"name":"running","value":true,"timestamp":"2026-07-23T10:00:00Z","error":""}
]
1
2
3
4
2
3
4
# Features
- Periodic collection: Place an
endpoint/scheduleendpoint before this node to trigger it on a schedule, and configure points inpointsbelow. For on-demand reads, an upstream node may inject points viamsg.Data. - Template variables: Point fields such as
addrsupport${msg.xx}/${metadata.xx}templates. - Dynamic points precedence: When
msg.Datacarries a valid points JSON array, it takes precedence; otherwise the configuredpointsare used. - Chain-scoped connection pool: Other S7 nodes in the same chain may reuse an established TCP connection via
ref://nodeIDto avoid duplicate connections. - Failure reconnect/retry: A connection-level failure (all points failed) triggers an automatic reconnect and retry, up to 3 times (
maxRetries=3). A single point failure is flagged with anerrormessage and does not interrupt the overall flow.
# Relation Type
- Success: Execution succeeds; the message is sent to the
Successchain. - Failure: Execution fails; the message is sent to the
Failurechain.
# Example
{
"ruleChain": {
"id": "s7_read_demo",
"name": "S7 read demo",
"root": true,
"debugMode": false
},
"metadata": {
"firstNodeIndex": 0,
"nodes": [
{
"type": "x/s7Read",
"name": "Read PLC data",
"debugMode": false,
"configuration": {
"server": "192.168.1.100:102",
"rack": 0,
"slot": 1,
"timeout": 5,
"points": [
{"name": "temperature", "addr": "DB1.DBD0", "type": "REAL"},
{"name": "counter", "addr": "DB1.DBD4", "type": "DINT"},
{"name": "running", "addr": "M10.5", "type": "BOOL"}
]
}
}
],
"connections": []
}
}
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
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
Edit this page on GitHub (opens new window)
Last Updated: 2026/07/29, 07:07:39