Skip to content

IndustryKit Siemens S7

The S7 source uses classic ISO-on-TCP to actively read the PLC's DB, Input, Output, and Marker areas.

Configuration hierarchy

Level Purpose
[[sources]] Defines an S7 collection task. Repeat it to configure multiple PLCs.
[sources.s7] Configures the PLC connection, rack/slot, and timeout for the current source.
[[sources.s7.points]] Defines one point to read. Each item adds one output field.

Each [[sources]] entry can contain only one protocol subtable. type = "s7" must correspond to [sources.s7]. field is the output field name written to the measurement, while area, db_number, and the offsets identify the location to read from the PLC.

Configuration

[[sources]]
id = "s7-plc"
type = "s7"
measurement = "s7_metrics"
interval = "10s"
tags = { device = "s7-1200" }

[sources.s7]
address = "192.0.2.40:102"
rack = 0
slot = 1
timeout = "3s"

[[sources.s7.points]]
field = "motor_speed"
area = "db"
db_number = 10
byte_offset = 0
data_type = "uint16"
scale = 0.1

[[sources.s7.points]]
field = "pump_running"
area = "db"
db_number = 10
byte_offset = 2
bit_offset = 0
data_type = "bool"

[[sources.s7.points]]
field = "batch_name"
area = "db"
db_number = 10
byte_offset = 8
data_type = "s7_string"
length = 20

Options

[[sources]]

Field Default Description
id None Required and unique within the configuration. It is also added as the source_id tag.
type None Must be set to s7.
measurement industrial Name of the reported metric measurement or log source.
interval 10s Polling interval. It must be greater than 0.
tags {} Static tags for this source.

[sources.s7]

Field Default Description
address None Required PLC address in host:port format. Classic S7 commonly uses port 102.
rack 0 CPU rack, in the range 0..7.
slot 1 CPU slot, in the range 1..31.
timeout 3s Timeout for one connection or read operation. It must be greater than 0.

[[sources.s7.points]]

Field Default Description
field None Required output field name.
category metric Output category: metric or logging.
tags {} Static tags for this point.
area None Required: db, input, output, or marker.
db_number 0 Must be greater than 0 when area = "db". It must be omitted or set to 0 for other areas.
byte_offset 0 Zero-based byte offset within the area.
bit_offset 0 Used only by bool, in the range 0..7. It must be 0 for other types.
data_type None Required: bool, int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64, string, s7_string, or bytes.
length 0 Must be 1..4096 for string/bytes, or 1..254 for s7_string. Do not set it for other types.
scale 1 Multiplier used for numeric transformation.
offset 0 Numeric transformation offset. The final value is value * scale + offset.
on_change false Whether a metric is sent only when its value changes. Logging data is always sent on change.
emit_initial false Whether to send the first observed value for logging data or a metric with on_change enabled.
status info Status field used only for logging data.

Data and limitations

  • Adjacent or overlapping addresses are combined by area/DB into reads of up to 4096 bytes each.
  • Integers and floating-point values are decoded using the big-endian byte order commonly used by S7.
  • Each source must contain at least one point, and a point's read range cannot exceed the S7 address space.
  • The same combination of field and final tags cannot be repeated.
  • S7-1200/1500 PLCs must have PUT/GET enabled and use non-optimized DB access.
  • Symbolic variables, automatic discovery, and PLC writes are not supported.

Feedback

Is this page helpful?