Skip to content

Siemens S7 Connector

The Siemens S7 connector enables direct communication with Siemens S7-series PLCs without requiring OPC UA or other middleware.

Connector Types:

  • S7Reader - Read data from S7 PLCs
  • S7Writer - Write data to S7 PLCs

Supported PLCs:

  • S7-300
  • S7-400
  • S7-1200
  • S7-1500
{
"type": "S7Reader",
"config": {
"endpoint": "192.168.0.1:102",
"pollingRate": 1000,
"rack": 0,
"slot": 2
},
"variables": [
{
"key": "temperature",
"dataType": "Real",
"memoryArea": "DB",
"blockNumber": 1,
"startIdx": 0,
"size": 4,
"bitOrder": "BigEndian"
},
{
"key": "counter",
"dataType": "Dint",
"memoryArea": "DB",
"blockNumber": 1,
"startIdx": 4,
"size": 4,
"bitOrder": "BigEndian"
}
]
}
{
"type": "S7Writer",
"config": {
"endpoint": "192.168.0.1:102",
"rack": 0,
"slot": 2
},
"variables": [
{
"key": "setpoint",
"dataType": "Real",
"memoryArea": "DB",
"blockNumber": 1,
"startIdx": 100,
"size": 4,
"bitOrder": "BigEndian"
}
]
}

PLC IP address and port (default port is 102):

{
"endpoint": "192.168.0.1:102"
}

Physical location of the CPU module:

{
"rack": 0,
"slot": 2
}

Common configurations:

  • S7-300: rack=0, slot=2
  • S7-400: rack=0, slot=2 or 3
  • S7-1200: rack=0, slot=1
  • S7-1500: rack=0, slot=1

For readers, interval in milliseconds:

{
"pollingRate": 1000
}

Most common area for structured data:

{
"key": "temperature",
"dataType": "Real",
"memoryArea": "DB",
"blockNumber": 1,
"startIdx": 0,
"size": 4
}

Requires blockNumber to specify which DB.

General-purpose memory:

{
"key": "flag_value",
"dataType": "Word",
"memoryArea": "M",
"startIdx": 0,
"size": 2
}

Physical input signals (read-only):

{
"key": "sensor_input",
"dataType": "Bool",
"memoryArea": "I",
"startIdx": 0,
"size": 1
}

Physical output signals (read/write):

{
"key": "motor_output",
"dataType": "Bool",
"memoryArea": "Q",
"startIdx": 0,
"size": 1
}

Counter values:

{
"key": "production_count",
"dataType": "Word",
"memoryArea": "C",
"startIdx": 0,
"size": 2
}

Boolean value:

{
"dataType": "Bool",
"size": 1
}

Unsigned 8-bit integer (0-255):

{
"dataType": "Byte",
"size": 1
}

Unsigned 16-bit integer (0-65535):

{
"dataType": "Word",
"size": 2
}

Unsigned 32-bit integer:

{
"dataType": "Dword",
"size": 4
}

Signed 16-bit integer (-32768 to 32767):

{
"dataType": "Int",
"size": 2
}

Signed 32-bit integer:

{
"dataType": "Dint",
"size": 4
}

32-bit floating point:

{
"dataType": "Real",
"size": 4
}

ASCII character:

{
"dataType": "Char",
"size": 1
}

S7 PLCs use Big Endian byte order by default:

{
"bitOrder": "BigEndian"
}

Complete variable definition:

{
"key": "temperature", // Meddle payload key
"dataType": "Real", // S7 data type
"memoryArea": "DB", // Memory area
"blockNumber": 1, // DB number (for DB area)
"startIdx": 0, // Start byte offset
"size": 4, // Size in bytes
"bitOrder": "BigEndian" // Byte order
}
{
"type": "S7Reader",
"config": {
"endpoint": "192.168.1.10:102",
"pollingRate": 1000,
"rack": 0,
"slot": 2
},
"variables": [
{
"key": "machine_status",
"dataType": "Word",
"memoryArea": "DB",
"blockNumber": 10,
"startIdx": 0,
"size": 2,
"bitOrder": "BigEndian"
},
{
"key": "production_count",
"dataType": "Dint",
"memoryArea": "DB",
"blockNumber": 10,
"startIdx": 2,
"size": 4,
"bitOrder": "BigEndian"
},
{
"key": "cycle_time",
"dataType": "Real",
"memoryArea": "DB",
"blockNumber": 10,
"startIdx": 6,
"size": 4,
"bitOrder": "BigEndian"
}
]
}
{
"type": "S7Writer",
"config": {
"endpoint": "192.168.1.10:102",
"rack": 0,
"slot": 2
},
"variables": [
{
"key": "temperature_setpoint",
"dataType": "Real",
"memoryArea": "DB",
"blockNumber": 20,
"startIdx": 0,
"size": 4,
"bitOrder": "BigEndian"
},
{
"key": "enable_process",
"dataType": "Bool",
"memoryArea": "M",
"startIdx": 0,
"size": 1,
"bitOrder": "BigEndian"
}
]
}
{
"type": "S7Reader",
"config": {
"endpoint": "192.168.1.10:102",
"pollingRate": 500,
"rack": 0,
"slot": 2
},
"variables": [
{
"key": "emergency_stop",
"dataType": "Bool",
"memoryArea": "I",
"startIdx": 0,
"size": 1,
"bitOrder": "BigEndian"
},
{
"key": "motor_running",
"dataType": "Bool",
"memoryArea": "Q",
"startIdx": 0,
"size": 1,
"bitOrder": "BigEndian"
}
]
}

Solutions:

  • Verify PLC IP address and port
  • Check network connectivity: ping [plc-ip]
  • Ensure PLC allows external connections (check PLC configuration)
  • Verify rack and slot numbers match your PLC configuration
  • Check firewall rules (port 102)

Solutions:

  • Check PLC protection settings
  • Verify PUT/GET communication is enabled in PLC
  • Ensure no password protection on the PLC
  • Check if PLC is in RUN mode (some operations require STOP mode)

Solutions:

  • Verify startIdx (byte offset) is correct
  • Check size matches the data type
  • Confirm blockNumber for DB areas
  • Verify bitOrder (should be BigEndian for S7)
  • Use TIA Portal or STEP 7 to verify memory layout

Solutions:

  • Increase pollingRate to reduce frequency
  • Group consecutive memory addresses
  • Reduce number of variables
  • Check network latency
  1. Use Data Blocks: Organize data in DBs for better structure
  2. Document Memory Layout: Keep a map of your DB structure
  3. Group Consecutive Addresses: More efficient than scattered reads
  4. Test in STOP Mode First: Safer for initial testing
  5. Use Appropriate Data Types: Match PLC program data types exactly