Monitoring Siemens S7 PLC
Monitor values and response time exposed by a Siemens S7 PLC over the S7 protocol.
Protocol: S7
Before You Begin
- Ensure the target PLC is reachable from the HertzBeat collector on the S7 TCP port (default:
102). - Ensure that the PLC permits the required S7 communication and read access to the configured addresses.
- Obtain the rack ID, slot ID, controller type, and readable variable addresses from the PLC configuration or the automation engineer.
HertzBeat uses Apache PLC4X plc4j-driver-s7 0.12.0 to communicate with the PLC. Address strings are passed to that driver without conversion. Use the PLC4X S7 address format that matches the target PLC and its variable data types.
Configuration Parameters
| Parameter | Description |
|---|---|
| S7 Server Host | IPv4 address, IPv6 address, or domain name of the target PLC. Do not include a protocol prefix such as s7://. |
| Port | S7 TCP port of the PLC. The template default is 102. |
| rackId | Remote PLC rack number. It must be numeric; the default is 0. |
| slotId | Remote PLC CPU slot number. It must be numeric; the default is 0. |
| controllerType | PLC controller type passed to the PLC4X S7 driver. The template default is S7_1500. Supported values are ANY, S7_200, S7_300, S7_400, S7_1200, S7_1500, and LOGO; select the value appropriate for the target controller. |
| Request Timeout (ms) | Maximum time to wait for a collection request. The template default is 6000 ms; valid values are 400 to 200000. This advanced parameter is hidden in the UI by default. |
| Holding Register Addresses | Required list of numeric or other non-Boolean PLC variables to read. Each item must be a valid PLC4X S7 tag address. |
| Coil Register Addresses | Required list of Boolean PLC variables to read. Each item must be a valid PLC4X S7 tag address. Boolean results are reported as 1 for true and 0 for false. |
Although the UI uses the names “holding register” and “coil” to group metrics consistently with the PLC collector, the values entered in both lists are native S7 tag addresses, not Modbus addresses.
Address Examples
The address must include the S7 memory location and data type. Common PLC4X S7 examples are:
| Purpose | Example address |
|---|---|
| Boolean in data block 1 | %DB1.DBX0.0:BOOL |
| 16-bit signed integer in data block 10 | %DB10.DBW20:INT |
| Boolean input | %I0.0:BOOL |
| 32-bit signed integer in marker memory | %MD100:DINT |
For a straightforward configuration, add four single-value addresses to each address list. The two metric sets each have four fixed output fields. HertzBeat checks that the number of values produced by each address list is exactly four. If an address uses the template's batch notation such as [n], it counts as n values; ensure the total expanded count is still four.
Collected Metrics
Metric Set: holding-register
This availability metric set runs first. A collection failure prevents the lower-priority coil metric set from running in that collection cycle.
| Metric | Unit | Description |
|---|---|---|
| responseTime | ms | Time required to complete the S7 read request. |
| address-0 | none | First value resolved from the Holding Register Addresses list. |
| address-1 | none | Second value resolved from the Holding Register Addresses list. |
| address-2 | none | Third value resolved from the Holding Register Addresses list. |
| address-3 | none | Fourth value resolved from the Holding Register Addresses list. |
Metric Set: coil
| Metric | Unit | Description |
|---|---|---|
| responseTime | ms | Time required to complete the S7 read request. |
| address-0 | none | First value resolved from the Coil Register Addresses list; Boolean values are converted to 0 or 1. |
| address-1 | none | Second value resolved from the Coil Register Addresses list; Boolean values are converted to 0 or 1. |
| address-2 | none | Third value resolved from the Coil Register Addresses list; Boolean values are converted to 0 or 1. |
| address-3 | none | Fourth value resolved from the Coil Register Addresses list; Boolean values are converted to 0 or 1. |
Troubleshooting
| Symptom | Check |
|---|---|
| Connection or timeout error | Verify network reachability to the configured host and port, then confirm that S7 communication is enabled on the PLC. |
| Connection established but reads fail | Check the rack ID, slot ID, controller type, and the PLC account or PLC project permissions. |
| Invalid address or tag read error | Verify the address syntax and data type against the PLC project and PLC4X S7 address format. |
| Template validation error about alias fields and addresses | Make sure each address list expands to exactly four values. |
| Only holding-register metrics are available | Resolve the holding-register collection error first; it is the priority-0 availability metric set. |