S7 Read/Write + Dashboard & PostgreSQL Logging

This Node-RED flow reads and writes a REAL value from a Siemens S7 PLC and extends it by logging the read value into a PostgreSQL database and visualizing it on a dashboard in real time. Useful for monitoring and controlling industrial processes while maintaining historical traceability.

[{"id":"1bc5eba7c0d861ad","type":"s7 in","z":"65b4cce16349e970","endpoint":"6f05c4f2e2b5be12","mode":"single","variable":"TankLevel","diff":false,"name":"Read TankLevel","x":150,"y":100,"wires":[["65aea8775a410bd2","eae98de5a999df9c","cdebebbb66358c66"]]},{"id":"65aea8775a410bd2","type":"debug","z":"65b4cce16349e970","name":"Debug Read","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":400,"y":60,"wires":[]},{"id":"4c771582fbd7aa83","type":"inject","z":"65b4cce16349e970","name":"Inject Write Value (e.g., 55.0)","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"55.0","payloadType":"num","x":170,"y":200,"wires":[["34fd6a7328d8f4b4"]]},{"id":"34fd6a7328d8f4b4","type":"s7 out","z":"65b4cce16349e970","endpoint":"6f05c4f2e2b5be12","variable":"TankLevel","name":"Write TankLevel","x":410,"y":200,"wires":[]},{"id":"eae98de5a999df9c","type":"ui_gauge","z":"65b4cce16349e970","name":"Tank Level Gauge","group":"d1b49fde1792eff2","order":1,"width":6,"height":4,"gtype":"gage","title":"Tank Level","label":"liters","format":"{{value}}","min":0,"max":100,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","diff":false,"className":"","x":420,"y":100,"wires":[]},{"id":"cdebebbb66358c66","type":"function","z":"65b4cce16349e970","name":"Prepare SQL Insert","func":"msg.topic = \"INSERT INTO tank_level_log(timestamp, value) VALUES (NOW(), $1);\";\nmsg.payload = [msg.payload];\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":140,"wires":[["0e642091f8e17b20"]]},{"id":"0e642091f8e17b20","type":"postgresql","z":"65b4cce16349e970","name":"PostgreSQL Insert","query":"","postgreSQLConfig":"","split":false,"rowsPerMsg":1,"outputs":1,"x":630,"y":140,"wires":[[]]},{"id":"6f05c4f2e2b5be12","type":"s7 endpoint","transport":"iso-on-tcp","port":"102","rack":"0","slot":"1","localtsaphi":"01","localtsaplo":"00","remotetsaphi":"01","remotetsaplo":"00","connmode":"rack-slot","adapter":"","cycletime":"1000","timeout":"2000","name":"S7-1200 PLC"},{"id":"d1b49fde1792eff2","type":"ui_group","name":"Monitoring","tab":"c4ac9c6eecfd8e74","order":1,"disp":true,"width":6},{"id":"c4ac9c6eecfd8e74","type":"ui_tab","name":"IsoSpec Dashboard","icon":"dashboard","order":1}]

Flow Info

Created 5 days ago
Rating:

Actions

Rate:

Node Types

Core
  • debug (x1)
  • function (x1)
  • inject (x1)
Other
  • postgresql (x1)
  • s7 endpoint (x1)
  • s7 in (x1)
  • s7 out (x1)
  • ui_gauge (x1)
  • ui_group (x1)
  • ui_tab (x1)

Tags

  • Siemens
  • PLC
  • Dashboard
  • PostgreSQL
  • Read
  • Write
  • Logging
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option