June 7, 2026

#304 - Node-RED integration with Siemens CPU

 - Download the latest Node-RED LTS version from the website.

- Install the .msi installer.

- From command line, launch: > npm install -g --unsafe-perm node-red

> node-red

- This will launch the node-red server on localhost (http://127.0.0.1:1880) and start the flow.

- Install the node-red-contrib-s7 library (Hamburger Menu Icon > Manage Palette).

- Setup the PLC connection and point to the desired variable in the DB.

The notation will depend on the data type for each variable, e.g.:

DB6,X102.0 (for BOOL).

S7 in: Reads data from PLC.

S7 out: Writes data to PLC.

Notes for PLC configuration:

- Enable PUT/GET communication (Protection & Security settings). A PLC error [0x8104] will occur on Node-RED if PUT/GET is disabled.

- Disable the optimized setting of the DB for the data exchange.

- Example of simple Node-Red flow (flows.json):

[
    {
        "id": "8076aca0f106d3fc",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "bcd87532b17d8ed7",
        "type": "s7 in",
        "z": "8076aca0f106d3fc",
        "endpoint": "fba2a3c3d78a6b11",
        "mode": "single",
        "variable": "DoorSwitch",
        "diff": false,
        "name": "DoorSwitch",
        "x": 150,
        "y": 160,
        "wires": [
            [
                "f63332c06dc180d3"
            ]
        ]
    },
    {
        "id": "f63332c06dc180d3",
        "type": "debug",
        "z": "8076aca0f106d3fc",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": true,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 370,
        "y": 160,
        "wires": []
    },
    {
        "id": "be9bfb11268dfe6d",
        "type": "debug",
        "z": "8076aca0f106d3fc",
        "name": "debug 2",
        "active": true,
        "tosidebar": true,
        "console": true,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 370,
        "y": 240,
        "wires": []
    },
    {
        "id": "0bc7bf7871457632",
        "type": "s7 in",
        "z": "8076aca0f106d3fc",
        "endpoint": "fba2a3c3d78a6b11",
        "mode": "single",
        "variable": "WaterIngress",
        "diff": false,
        "name": "WaterIngress",
        "x": 150,
        "y": 240,
        "wires": [
            [
                "be9bfb11268dfe6d"
            ]
        ]
    },
    {
        "id": "fba2a3c3d78a6b11",
        "type": "s7 endpoint",
        "transport": "iso-on-tcp",
        "address": "192.168.0.1",
        "port": "102",
        "rack": "0",
        "slot": "1",
        "localtsaphi": "01",
        "localtsaplo": "00",
        "remotetsaphi": "01",
        "remotetsaplo": "00",
        "connmode": "rack-slot",
        "adapter": "",
        "busaddr": 2,
        "cycletime": 1000,
        "timeout": 2000,
        "name": "PLC_IN",
        "vartable": [
            {
                "addr": "DB6,X102.0",
                "name": "DoorSwitch"
            },
            {
                "addr": "DB6,X102.1",
                "name": "WaterIngress"
            }
        ]
    },
    {
        "id": "caf7f9537a7dec51",
        "type": "global-config",
        "env": [],
        "modules": {
            "node-red-contrib-s7": "3.1.3"
        }
    }
]

No comments:

Post a Comment