Skip to main content

Siemens S7 Overview

The SIEMENS_S7 route enables direct communication with Siemens S7 PLCs using the native S7 protocol (ISO-on-TCP). It supports all major S7 PLC families and provides access to data blocks, memory areas, inputs, outputs, timers, and counters.
The S7 route uses native protocol communication, which is typically faster and more efficient than OPC UA for Siemens PLCs.

Basic Syntax


Supported CPU Types

For S7-1200/1500 PLCs, you may need to enable “Permit access with PUT/GET” in the PLC’s protection settings (Hardware Configuration → Protection & Security).

Connection Configuration

S7_CONFIG Parameters

IP
string
required
S7 PLC IP address.
CPU_TYPE
string
required
CPU type: S7200, S7300, S7400, S71200, or S71500.
RACK
integer
PLC rack number. Default: 0.
SLOT
integer
PLC slot number. Default: 1 for S7-1200/1500, 2 for S7-300/400.
CONNECTION_TYPE
string
Connection type: PG (Programming device), OP (Operator Panel), or S7BASIC. Default: PG.
RETRY_ATTEMPTS
integer
Number of retry attempts on failure. Default: 3.
RETRY_TIME_SECONDS
integer
Seconds to wait between retries. Default: 5.
REFRESH_TIME_MS
integer
Refresh time in milliseconds. Default: 1000.
READ_TIMEOUT
integer
Read timeout in milliseconds. Default: 5000.
WRITE_TIMEOUT
integer
Write timeout in milliseconds. Default: 5000.

Connection Examples


S7 Addressing

Address Format

S7 addresses follow the pattern: <Area><Number>.<Offset> or <DB>.<Type><Offset>

Address Types

ADDRESS_TYPE
string
Memory area type: DATABLOCK, MEMORY, INPUT, OUTPUT, TIMER, COUNTER.
For most configurations, the ADDRESS_TYPE is inferred from the address format. Use explicit ADDRESS_TYPE when needed for clarity.

Data Types


TAG Configuration

Complete TAG Example

TAG Parameters

ADDRESS
string
required
S7 address in standard notation (e.g., DB1.DBW100, M0.0, I0.0, Q0.0).
ADDRESS_TYPE
string
Address type: DATABLOCK, MEMORY, INPUT, OUTPUT, TIMER, COUNTER.
DATA_TYPE
string
required
S7 data type: BOOL, BYTE, WORD, DWORD, INT, DINT, REAL, STRING.
SCALING
double
Multiplier applied to raw value. Default: 1.0.
OFFSET
double
Value added after scaling. Default: 0.0.
DECIMAL_PLACES
integer
Number of decimal places in output. Default: 2.
MIN_VALUE
double
Minimum allowed value.
MAX_VALUE
double
Maximum allowed value.
DEADBAND
double
Minimum change to trigger publish. Default: 0.0.
SOURCE_TOPIC
string
Topic where PLC values are published. Subscribe here to receive sensor data.
PUBLISH_MODE
string
Output format: VALUE_ONLY or JSON. Default: VALUE_ONLY.
UNIT
string
Engineering unit (e.g., °C, bar, RPM).
WRITABLE
boolean
Allow writing to this address. Default: false.
DESTINATION_TOPIC
string
Topic to send write commands. Publish a value here to write it to the PLC.

Event-Based Operations

For on-demand S7 operations (not polling), use the EVENT syntax. Publish a message to SOURCE_TOPIC to trigger the operation; the route executes it and publishes the result to DESTINATION_TOPIC.

Supported Operations

Query Parameters

Read Example

Read 10 words from Data Block 1 on demand:

Write Example

Write a REAL value to Data Block 10 on demand:

Complete Examples

Read values from a data block:

S7-1200/1500 Setup

S7-1200 and S7-1500 PLCs require additional configuration to allow external access.

Enable PUT/GET Access

  1. Open TIA Portal project
  2. Navigate to Device ConfigurationProperties
  3. Go to Protection & SecurityConnection mechanisms
  4. Enable Permit access with PUT/GET communication from remote partner

Optimized Block Access

For S7-1500, ensure data blocks are set to allow standard access:
  1. Open the Data Block in TIA Portal
  2. In Properties, uncheck Optimized block access
  3. Compile and download to PLC

Troubleshooting

  • Verify IP address is correct
  • Check PLC is in RUN mode
  • For S7-1200/1500: Enable PUT/GET access
  • Verify correct RACK and SLOT settings
  • Check firewall allows TCP port 102
Use correct slot for your CPU:
  • S7-1200/1500: Slot 1
  • S7-300: Slot 2
  • S7-400: Slot 2 or 3 (check hardware config)
For S7-1500: Disable optimized block access in TIA Portal for data blocks you want to access.
  • Verify address matches TIA Portal
  • Check DATA_TYPE corresponds to PLC variable type
  • For multi-word types, verify byte offset is correct
  • Check BYTE_ORDER if values seem swapped
  • Ensure WRITABLE is set to “true”
  • Verify PLC is in RUN mode
  • Check access permissions in PLC
  • Confirm value is within MIN_VALUE/MAX_VALUE

Next Steps

OPC UA

Cross-platform industrial communication.

ADS (Beckhoff)

Connect to TwinCAT systems.
Last modified on May 22, 2026