{"id":14748,"library":"node-red-contrib-s7comm","title":"Node-RED Siemens S7 PLC Communication","description":"node-red-contrib-s7comm is a Node-RED package designed to facilitate communication with Siemens SIMATIC S7-300, S7-1200, and S7-1500 PLCs. It leverages the RFC1006 (ISO-on-TCP) communication protocol, enabling users to read from and write to specific PLC addresses using various S7 data types. The current stable version is 1.1.6. As a Node-RED contribution node, its release cadence is typically driven by community contributions and updates to its underlying `nodeS7` library, which handles the core PLC communication. Key differentiators include its integration into the Node-RED flow-based programming environment, simplifying the creation of HMI, SCADA, or IIoT applications that interact with Siemens PLCs without requiring extensive low-level protocol knowledge. It abstracts the complexities of the S7comm protocol behind user-friendly Node-RED nodes.","status":"active","version":"1.1.6","language":"javascript","source_language":"en","source_url":"https://github.com/Hilscher/node-red-contrib-s7comm","tags":["javascript","node-red","SIMATIC","PLC","Siemens","S7","S7comm","RFC1006","iso-on-tcp"],"install":[{"cmd":"npm install node-red-contrib-s7comm","lang":"bash","label":"npm"},{"cmd":"yarn add node-red-contrib-s7comm","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-red-contrib-s7comm","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the core S7 communication framework for interacting with Siemens PLCs.","package":"nodeS7","optional":false}],"imports":[{"note":"As a Node-RED contrib package, this node is primarily configured and used within the Node-RED flow editor. Direct programmatic JavaScript/TypeScript `import` statements for users are not the intended interaction method. The entries here are illustrative of what internal components *might* be exposed if it were a standard library, but are not for typical user consumption.","symbol":"S7CommNode","correct":"/* This package is a Node-RED node. Users do not typically import symbols directly into JavaScript. */"},{"note":"Configuration nodes for Node-RED are managed by the runtime and exposed via the editor's palette. Users define instances of these nodes graphically.","symbol":"S7ConfigNode","correct":"/* This package is a Node-RED node. Users do not typically import symbols directly into JavaScript. */"},{"note":"While an underlying S7 client (from `nodeS7`) is used internally, it is not directly exposed for programmatic import by users of `node-red-contrib-s7comm`. Interaction is abstracted through Node-RED's message passing system.","symbol":"S7Client","correct":"/* This package is a Node-RED node. Users do not typically import symbols directly into JavaScript. */"}],"quickstart":{"code":"// To install the Node-RED node:\n// 1. Ensure Node-RED is installed and running.\n// 2. Open the Node-RED editor (usually http://localhost:1880).\n// 3. Go to the Palette Manager (top-right menu -> Manage palette).\n// 4. In the 'Install' tab, search for 'node-red-contrib-s7comm' and click install.\n\n// After installation, drag 's7comm read' and 's7comm write' nodes from the palette onto your flow.\n// Example JavaScript code showing conceptual S7 client usage, not direct 'node-red-contrib-s7comm' usage:\n\n// import { S7Client } from 'nodeS7'; // Hypothetical import if using nodeS7 directly\n\n// async function readS7Data() {\n//   const client = new S7Client();\n//   try {\n//     await client.connect({\n//       host: '192.168.0.1',\n//       port: 102,\n//       rack: 0,\n//       slot: 1\n//     });\n//     console.log('Connected to PLC.');\n\n//     const data = await client.readArea(\n//       S7Client.S7Area.DB,\n//       1, // DB number\n//       0, // Start offset\n//       2, // Length (e.g., 2 bytes)\n//       S7Client.S7Type.WORD\n//     );\n//     console.log('Read data:', data);\n//   } catch (error) {\n//     console.error('S7 communication error:', error);\n//   } finally {\n//     client.destroy();\n//   }\n// }\n\n// readS7Data();","lang":"javascript","description":"Illustrates the typical installation process for Node-RED packages via the Palette Manager and provides a conceptual JavaScript snippet for direct S7 client interaction (not directly from this Node-RED node)."},"warnings":[{"fix":"In TIA Portal, navigate to the PLC properties, then 'Protection & Security', and enable 'Permit access with PUT/GET communication from remote partner (PLC, HMI, OPC)'.","message":"Siemens S7-1200/1500 PLCs require specific 'Protection & Security' settings in TIA Portal (e.g., 'Permit access with PUT/GET communication from remote partner') to allow external read/write access via S7comm. Failure to configure this will result in connection refusal.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always cross-check the configured S7 data type (e.g., BYTE, WORD, INT, REAL, BOOL) and array length in the Node-RED node against the PLC's TIA Portal project variables for exact matches.","message":"Incorrect S7 data type or length configuration in the Node-RED node can lead to read/write errors, corrupted data, or unexpected values. The node expects precise mapping to the PLC's actual data block structure.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"After making changes to S7comm nodes or their configuration nodes, perform a 'Full deploy' in Node-RED to ensure all nodes are correctly initialized with the latest settings. Check the Node-RED debug tab for errors.","message":"Node-RED flow deployments, especially involving configuration nodes, must be handled carefully. Partial or incorrect deployments can result in nodes remaining uninitialized or losing their connection settings.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Monitor the GitHub repositories for both `node-red-contrib-s7comm` and `nodeS7` for updates and security advisories. Ensure you are running the latest stable versions of both.","message":"The stability and security of `node-red-contrib-s7comm` are dependent on the underlying `nodeS7` library. Any vulnerabilities or critical bugs discovered in `nodeS7` will directly impact this Node-RED contribution.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Verify the PLC's IP address and port (default 102), check network connectivity between Node-RED host and PLC, ensure no firewall is blocking port 102, and confirm PLC 'Protection & Security' settings allow PUT/GET communication.","cause":"The PLC rejected the connection attempt, often due to incorrect IP, port, firewall blocking, or PLC security settings.","error":"Error: Connection refused"},{"fix":"In the Node-RED node's configuration, precisely match the S7 data type (e.g., INT, REAL) and length to what is defined in the TIA Portal for the target PLC address (DB, address, size).","cause":"The configured data length or type in the Node-RED node does not match the actual data block/variable size on the PLC.","error":"Error: S7 response data error - wrong data size"},{"fix":"Check the PLC's 'Protection & Security' settings in TIA Portal for PUT/GET permissions. For data blocks, ensure 'Optimized block access' is not solely enabled if the client expects standard access, or vice-versa, and verify block attributes.","cause":"Generic PLC communication error, frequently indicating that the PLC's security settings prevent access to the requested data block or an unsupported access method.","error":"Error: S7 PLC response: 10/FF00"},{"fix":"Ensure that your 's7comm read' or 's7comm write' node is correctly linked to an 's7comm-config' node, and that the 's7comm-config' node is also properly configured. Perform a 'Full deploy' in Node-RED after making changes.","cause":"This error typically occurs within Node-RED when a node's associated configuration node (e.g., the S7comm-Config node) is either missing, unlinked, or not properly deployed.","error":"TypeError: Cannot read properties of undefined (reading 'config')"}],"ecosystem":"npm"}