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

DEFINE ROUTE SiemensPLC WITH TYPE SIEMENS_S7
    ADD S7_CONFIG
        WITH IP "192.168.1.100"
        WITH CPU_TYPE "S71500"
        WITH RACK '0'
        WITH SLOT '1'
    ADD MAPPING ProcessData
        WITH EVERY 500 MILLISECONDS
        ADD TAG Temperature
            WITH ADDRESS "DB1.DBD100"
            WITH DATA_TYPE "REAL"
            WITH SOURCE_TOPIC "plc/temperature"

Supported CPU Types

CPU TypeParameter ValueTypical SlotDescription
S7-200S72000Compact micro PLCs
S7-300S73002Modular PLCs
S7-400S74002/3High-performance PLCs
S7-1200S712001Compact controllers
S7-1500S715001Advanced controllers
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

ADD S7_CONFIG
    WITH IP "192.168.1.100"
    WITH CPU_TYPE "S71500"
    WITH RACK '0'
    WITH SLOT '1'
    WITH CONNECTION_TYPE "PG"

S7 Addressing

Address Format

S7 addresses follow the pattern: <Area><Number>.<Offset> or <DB>.<Type><Offset>
AddressDescriptionExample
DBn.DBXx.yData Block bitDB1.DBX0.0 - DB1, byte 0, bit 0
DBn.DBBxData Block byteDB1.DBB0 - DB1, byte 0
DBn.DBWxData Block word (16-bit)DB1.DBW100 - DB1, word at byte 100
DBn.DBDxData Block double word (32-bit)DB1.DBD100 - DB1, dword at byte 100
Mx.yMemory bitM0.0 - Marker byte 0, bit 0
MBxMemory byteMB0 - Marker byte 0
MWxMemory wordMW100 - Marker word at byte 100
MDxMemory double wordMD100 - Marker dword at byte 100
Ix.yInput bitI0.0 - Input byte 0, bit 0
IBxInput byteIB0 - Input byte 0
IWxInput wordIW0 - Input word at byte 0
Qx.yOutput bitQ0.0 - Output byte 0, bit 0
QBxOutput byteQB0 - Output byte 0
QWxOutput wordQW0 - Output word at byte 0
TxTimerT0 - Timer 0
CxCounterC0 - Counter 0

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

Data TypeS7 TypeSizeDescription
BOOLBOOL1 bitBoolean value
BYTEBYTE8 bitsUnsigned 8-bit
WORDWORD16 bitsUnsigned 16-bit
DWORDDWORD32 bitsUnsigned 32-bit
INT / INT16INT16 bitsSigned 16-bit integer
UINT16UINT16 bitsUnsigned 16-bit integer
DINT / INT32DINT32 bitsSigned 32-bit integer
UINT32UDINT32 bitsUnsigned 32-bit integer
REAL / FLOATREAL32 bits32-bit floating point
STRINGSTRINGVariableS7 string type

TAG Configuration

Complete TAG Example

ADD TAG ProcessTemperature
    WITH ADDRESS "DB1.DBD100"
    WITH ADDRESS_TYPE "DATABLOCK"
    WITH DATA_TYPE "REAL"
    WITH SOURCE_TOPIC "plc/process/temperature"
    WITH SCALING "1"
    WITH OFFSET "0"
    WITH UNIT "°C"
    WITH DECIMAL_PLACES "2"
    WITH MIN_VALUE "-50"
    WITH MAX_VALUE "200"
    WITH DEADBAND "0.5"
    WITH PUBLISH_MODE "JSON"
    WITH WRITABLE "true"
    WITH DESTINATION_TOPIC "plc/process/temperature/set"
    WITH BYTE_ORDER "BIGENDIAN"
    WITH DESCRIPTION "Main process temperature"

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
MQTT topic for read values.
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
MQTT topic for write commands.

Event-Based Operations

For on-demand operations:
ADD EVENT ReadOnDemand
    WITH SOURCE_TOPIC "s7/commands/read"
    WITH DESTINATION_TOPIC "s7/responses/read"
    WITH QUERY '{"operation": "READ", "address": "DB1.DBW0", "data_type": "WORD", "count": 10}'

Complete Examples

Read values from a data block:
DEFINE ROUTE ProductionPLC WITH TYPE SIEMENS_S7
    ADD S7_CONFIG
        WITH IP "192.168.1.100"
        WITH CPU_TYPE "S71500"
        WITH RACK '0'
        WITH SLOT '1'
    ADD MAPPING ProductionData
        WITH EVERY 500 MILLISECONDS
        ADD TAG Temperature
            WITH ADDRESS "DB1.DBD0"
            WITH DATA_TYPE "REAL"
            WITH SOURCE_TOPIC "plc/temperature"
            WITH UNIT "°C"
        ADD TAG Pressure
            WITH ADDRESS "DB1.DBD4"
            WITH DATA_TYPE "REAL"
            WITH SOURCE_TOPIC "plc/pressure"
            WITH UNIT "bar"
        ADD TAG Speed
            WITH ADDRESS "DB1.DBW8"
            WITH DATA_TYPE "INT"
            WITH SOURCE_TOPIC "plc/speed"
            WITH UNIT "RPM"
        ADD TAG Running
            WITH ADDRESS "DB1.DBX10.0"
            WITH DATA_TYPE "BOOL"
            WITH SOURCE_TOPIC "plc/running"

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