Node-RED Siemens S7 PLC Connector
node-red-contrib-s7 is a Node-RED package designed to facilitate interaction with Siemens S7 series Programmable Logic Controllers (PLCs), including S7-300, S7-400, S7-1200, and S7-1500. Currently stable at version 3.1.3, this package offers a robust solution for integrating industrial automation into Node-RED flows. It provides specialized nodes—'S7 Endpoint' for connection management and variable configuration, and 'S7 In' for reading data—that are accessed directly through the Node-RED editor palette. Its key differentiators include a custom, simplified variable addressing scheme, support for various PLC data types (Boolean, Byte, Char, Int, DInt, Real, String), and flexible data retrieval modes (single variable, all variables per message, or all variables as a single object). The package is actively maintained, with updates typically aligned with Node-RED and Node.js LTS releases. Users should be aware of specific Node.js and Node-RED version requirements for compatibility. It originates from the ST-One project, emphasizing its industrial application focus.
Common errors
-
Error: Cannot find module 'node-red-contrib-s7'
cause The package was either not installed correctly, or Node-RED is not running in the appropriate user directory where the package was installed.fixRun `npm install node-red-contrib-s7` in your Node-RED user directory (typically `~/.node-red` on Linux or `%HOMEPATH%\.nodered` on Windows), or use the 'Manage Palette' feature in the Node-RED UI. -
Failed to load node file: /path/to/node-red-contrib-s7/nodes/s7-config.js (or similar error message indicating node loading failure)
cause This error typically indicates an incompatibility issue with your Node.js or Node-RED version, or a corrupted package installation.fixVerify that your Node.js version is 10+ and Node-RED is 1.0+. If versions are correct, try reinstalling the package by running `npm uninstall node-red-contrib-s7 && npm install node-red-contrib-s7` in your Node-RED user directory.
Warnings
- gotcha When using the 'All variables, one per message' mode in the S7 In node without 'diff' checked, be cautious of potential high message rates. This can flood your Node-RED flow and impact performance significantly.
- breaking This package has strict runtime environment requirements: Node.js version 10 or greater and Node-RED version 1.0 or greater. Installing or running on older versions will lead to errors and malfunction.
- gotcha The variable addressing scheme used within the S7 Endpoint node is custom to this package and differs 'slightly' from standard Siemens Step 7 or TIA Portal conventions. Direct translation may not work.
Install
-
npm install node-red-contrib-s7 -
yarn add node-red-contrib-s7 -
pnpm add node-red-contrib-s7
Imports
- S7 Endpoint (Node-RED Node)
import { S7Endpoint } from 'node-red-contrib-s7'Available in the Node-RED palette after installation. Drag and drop to configure a PLC connection.
- S7 In (Node-RED Node)
const S7In = require('node-red-contrib-s7').S7InAvailable in the Node-RED palette after installation. Drag and drop to read variables from a configured S7 Endpoint.
- S7 Out (Node-RED Node)
import * as S7 from 'node-red-contrib-s7'
Available in the Node-RED palette after installation (for writing data to PLC variables). Drag and drop into a flow.
Quickstart
npm install node-red-contrib-s7
// After successful installation, open your Node-RED editor (e.g., http://localhost:1880).
// The S7 nodes ('S7 Endpoint', 'S7 In', 'S7 Out') will appear in the Node-RED palette.
//
// 1. Drag an 'S7 Endpoint' node onto your flow canvas.
// 2. Double-click the 'S7 Endpoint' node to configure its properties:
// - Set the PLC's IP Address (e.g., '192.168.0.100').
// - Configure Rack and Slot if necessary (default 0,0 for S7-1200/1500).
// - Add variables you want to read/write, specifying their Name and custom Address (e.g., 'MyTemperature', 'DB1,REAL0').
// 3. Drag an 'S7 In' node onto your flow.
// 4. Double-click the 'S7 In' node, select the configured 'S7 Endpoint' from the dropdown.
// 5. Choose a 'Mode' (e.g., 'Single variable') and select one of the variables configured in the endpoint (e.g., 'MyTemperature').
// 6. Connect the 'S7 In' node's output to a 'debug' node to view the PLC data in the Node-RED debug sidebar.
// 7. Deploy the flow.