There is a new package available for Node-RED that enables the user to communicate with the PLCnext controller via the REST api. The name of the package is node-red-plc-next-connector. It can be installed via the “Managa palette” menu in Node-RED.
![](http://www.plcnext-community.net/app/uploads/2022/05/Picture1.png)
The package includes nodes to browse the available variables and datatypes, to read and write variables and to handle sessions and groups.
![](http://www.plcnext-community.net/app/uploads/2022/05/Picture2.png)
The first example shows how to browse all available variables. At the beginning, a new plc-connector must be created, i.e. a connection to the PLC must be configured. This plc-connector can then be used for all other nodes as well.
![](http://www.plcnext-community.net/app/uploads/2022/05/Picture3.png)
![](http://www.plcnext-community.net/app/uploads/2022/05/Picture4-1.png)
![](http://www.plcnext-community.net/app/uploads/2022/05/Bild5-1.png)
The result is returned as a dictionary.
![](http://www.plcnext-community.net/app/uploads/2022/05/Picture6.png)
Reading variables from the PLC is also very simple. In the read variables node, the plcnext connector must be selected. After that, you can select the variables from a dropdown list. The result is returned as an array of struct, containing the variaable path and the value.
![](http://www.plcnext-community.net/app/uploads/2022/05/Picture7.png)
![](http://www.plcnext-community.net/app/uploads/2022/05/Picture8-1.png)
![](http://www.plcnext-community.net/app/uploads/2022/05/Picture9-1.png)
The writing of variables works the same way. The plc-write-variables node expects the msg.payload in json format.
Here is an example payload:
msg.payload= {variables : [ { "path": "Arp.Plc.Eclr/I_WarehouseControl1.HMI_rTemperature", "value": 12.34, "valueType": "Constant" }, { "path": "Arp.Plc.Eclr/I_WarehouseControl1.HMI_iHumidity", "value": 85, "valueType": "Constant" } ]};
Leave a Reply
You must be logged in to post a comment.