Siemens S7 Connector
Overview
Section titled “Overview”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 PLCsS7Writer- Write data to S7 PLCs
Supported PLCs:
- S7-300
- S7-400
- S7-1200
- S7-1500
Basic Configuration
Section titled “Basic Configuration”S7 Reader
Section titled “S7 Reader”{ "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" } ]}S7 Writer
Section titled “S7 Writer”{ "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" } ]}Configuration Parameters
Section titled “Configuration Parameters”Endpoint
Section titled “Endpoint”PLC IP address and port (default port is 102):
{ "endpoint": "192.168.0.1:102"}Rack and Slot
Section titled “Rack and Slot”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
Polling Rate
Section titled “Polling Rate”For readers, interval in milliseconds:
{ "pollingRate": 1000}Memory Areas
Section titled “Memory Areas”DB (Data Blocks)
Section titled “DB (Data Blocks)”Most common area for structured data:
{ "key": "temperature", "dataType": "Real", "memoryArea": "DB", "blockNumber": 1, "startIdx": 0, "size": 4}Requires blockNumber to specify which DB.
M (Merkers/Flags)
Section titled “M (Merkers/Flags)”General-purpose memory:
{ "key": "flag_value", "dataType": "Word", "memoryArea": "M", "startIdx": 0, "size": 2}I (Inputs)
Section titled “I (Inputs)”Physical input signals (read-only):
{ "key": "sensor_input", "dataType": "Bool", "memoryArea": "I", "startIdx": 0, "size": 1}Q (Outputs)
Section titled “Q (Outputs)”Physical output signals (read/write):
{ "key": "motor_output", "dataType": "Bool", "memoryArea": "Q", "startIdx": 0, "size": 1}C (Counters)
Section titled “C (Counters)”Counter values:
{ "key": "production_count", "dataType": "Word", "memoryArea": "C", "startIdx": 0, "size": 2}Data Types
Section titled “Data Types”Bool (1 bit)
Section titled “Bool (1 bit)”Boolean value:
{ "dataType": "Bool", "size": 1}Byte (8 bit)
Section titled “Byte (8 bit)”Unsigned 8-bit integer (0-255):
{ "dataType": "Byte", "size": 1}Word (16 bit)
Section titled “Word (16 bit)”Unsigned 16-bit integer (0-65535):
{ "dataType": "Word", "size": 2}Dword (32 bit)
Section titled “Dword (32 bit)”Unsigned 32-bit integer:
{ "dataType": "Dword", "size": 4}Int (16 bit signed)
Section titled “Int (16 bit signed)”Signed 16-bit integer (-32768 to 32767):
{ "dataType": "Int", "size": 2}Dint (32 bit signed)
Section titled “Dint (32 bit signed)”Signed 32-bit integer:
{ "dataType": "Dint", "size": 4}Real (32 bit float)
Section titled “Real (32 bit float)”32-bit floating point:
{ "dataType": "Real", "size": 4}Char (8 bit ASCII)
Section titled “Char (8 bit ASCII)”ASCII character:
{ "dataType": "Char", "size": 1}Byte Order
Section titled “Byte Order”S7 PLCs use Big Endian byte order by default:
{ "bitOrder": "BigEndian"}Variable Structure
Section titled “Variable Structure”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}Common Use Cases
Section titled “Common Use Cases”1. Production Monitoring
Section titled “1. Production Monitoring”{ "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" } ]}2. Process Control
Section titled “2. Process Control”{ "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" } ]}3. Digital I/O Monitoring
Section titled “3. Digital I/O Monitoring”{ "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" } ]}Troubleshooting
Section titled “Troubleshooting”Connection Failed
Section titled “Connection Failed”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)
Access Denied
Section titled “Access Denied”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)
Wrong Data Values
Section titled “Wrong Data Values”Solutions:
- Verify
startIdx(byte offset) is correct - Check
sizematches the data type - Confirm
blockNumberfor DB areas - Verify
bitOrder(should be BigEndian for S7) - Use TIA Portal or STEP 7 to verify memory layout
Slow Performance
Section titled “Slow Performance”Solutions:
- Increase
pollingRateto reduce frequency - Group consecutive memory addresses
- Reduce number of variables
- Check network latency
Best Practices
Section titled “Best Practices”- Use Data Blocks: Organize data in DBs for better structure
- Document Memory Layout: Keep a map of your DB structure
- Group Consecutive Addresses: More efficient than scattered reads
- Test in STOP Mode First: Safer for initial testing
- Use Appropriate Data Types: Match PLC program data types exactly
Limitations
Section titled “Limitations”Related Connectors
Section titled “Related Connectors”- OPC UA - Alternative with broader support
- Modbus - Alternative industrial protocol
- Filter - Filter S7 data
- InfluxDB Writer - Store S7 data