Read and Write OPC UA Values in Node-RED

This Node-RED flow demonstrates how to connect to an OPC UA server to both read and write data values. It uses the OpcUa-Item node to specify the target nodes and includes basic logic for periodic reading and conditional writing. Ideal for industrial automation or IoT projects involving PLC communication over the OPC UA protocol.

[{"id":"17a1fc0d2d3fc86c","type":"inject","z":"a3771d5a74a10df6","name":"Refresh every 5s","props":[],"repeat":"5","crontab":"","once":true,"onceDelay":"","topic":"","x":1650,"y":660,"wires":[["d01fc24b03eb694e"]]},{"id":"683cbe615d1e2559","type":"OpcUa-Client","z":"a3771d5a74a10df6","endpoint":"","action":"read","deadbandvalue":"","time":"1","timeUnit":"s","localfile":"","localkeyfile":"","useTransport":false,"maxChunkCount":"","maxMessageSize":"","receiveBufferSize":"","sendBufferSize":"","setstatusandtime":false,"keepsessionalive":false,"name":"OPC UA Client","x":2040,"y":660,"wires":[["39d08c4ba17d6108"],[],[]]},{"id":"39d08c4ba17d6108","type":"debug","z":"a3771d5a74a10df6","name":"Data Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2230,"y":640,"wires":[]},{"id":"d01fc24b03eb694e","type":"OpcUa-Item","z":"a3771d5a74a10df6","item":"","datatype":"Double","value":"","name":"Read data","x":1850,"y":660,"wires":[["683cbe615d1e2559"]]},{"id":"e1703cc5d6004090","type":"inject","z":"a3771d5a74a10df6","name":"Write Data","props":[],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","x":1620,"y":740,"wires":[["b9bf6181bc9d661c"]]},{"id":"77eb0f359c58cf21","type":"OpcUa-Client","z":"a3771d5a74a10df6","endpoint":"","action":"write","deadbandvalue":"","time":"1","timeUnit":"s","localfile":"","localkeyfile":"","useTransport":false,"maxChunkCount":"","maxMessageSize":"","receiveBufferSize":"","sendBufferSize":"","setstatusandtime":false,"keepsessionalive":false,"name":"OPC UA Client","x":2040,"y":740,"wires":[["4b1b7b7921a35994"],[],[]]},{"id":"4b1b7b7921a35994","type":"debug","z":"a3771d5a74a10df6","name":"Result Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2240,"y":720,"wires":[]},{"id":"b9bf6181bc9d661c","type":"OpcUa-Item","z":"a3771d5a74a10df6","item":"","datatype":"Double","value":"","name":"Write Data","x":1850,"y":740,"wires":[["77eb0f359c58cf21"]]}]

Flow Info

Created 2 days ago
Rating: not yet rated

Actions

Rate:

Node Types

Core
  • debug (x2)
  • inject (x2)
Other
  • OpcUa-Client (x2)
  • OpcUa-Item (x2)

Tags

  • OPC-UA
  • Node-RED
  • Industrial_Automation
  • PLC
  • IoT
  • Read
  • Write
  • OpcUa-Item
  • SCADA
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option