OPC UA is an encrypted, secure protocol with options for deterministic performance developed by the OPC Foundation, it stands for OPC: OLE for Process Control, where OLE refers to Object Linking and Embedding; UA means, Unified Architecture.
In order to integrate data coming from a PLCnext device using OPC UA into Ubidots, we need to follow these steps:
First, set up an OPC UA server on your device so a third-party application can read its tags or variables.
Second, set up a client to interact with the PLCnext controller via OPC UA protocol and obtain the namespace, data type, and other parameters that can be used in other OPCUA client applications (such as Node-Red).
Finally, set up a Node-Red flow to read the PLC variables and send the information to Ubidots using our palette. This guide is based on the following manual designed by Phoenix contact and can be downloaded here.
Important Note: It is assumed that you already have interacted with PLCnext software and have programmed a PLC automation application, otherwise, please refer to Intro To Programming PLCnext IEC611-31 video.
Requirements
Access to PLCnext Engineer Software to set up the Server.
UAExpert Software from United Automation for the OPC UA Client.
Node-Red, either running locally or installed into the PLCnext controller.
An Ubidots account.
Table of contents
1. Set up an OPC UA Server
Open the PLCnext Engineer software and follow the instructions on pages 6 to 9 of the PLCnext “Getting started with OPC -UA Manual”. It is also recommended to go along with the first three minutes of this video.
2. Set up an OPC UA Client with the UAExpert Software
Register, download, and install the UAExpert software available here to set up an OPC UA client as indicated on pages 10 to 15 of the same manual, paying special attention to page 15 where you can see what data is relevant to bringing data from the PLC onto a Node-Red application. It is also suggested to go along with the rest of the same video from min 3:20 until the end.
3. Create a Node-Red OPC UA Client
This guide assumed that you already installed Node-Red but in case you have not, please make sure to do so, keep in mind that you would need to install node.js and this may require administrative privileges.
In Node-red go to the palette and install the node-red-contrib-opcua node as follows.
From here you can go along with pages 24 to 29 of the manual and also with the first 4 minutes of this video. In order to extract data using that node, you must have at hand the information obtained with the UAExpert Software, that data is required when configuring the topic on the inject node.
Bear in mind that we will not focus on watching the data in a node-red dashboard. From this point on, we will be using the Ubidots palette to get those values on the cloud, in your Ubidots account, and in a dashboard there.
4. Integrate your Node-Red application to your Ubidots account
Convert the raw data into a JSON Object
Here we will use a function node that helps to wrap up the raw data coming from the PLC into a JSON object compatible with the Ubidots platform, it receives a value coming from the PLC and forms a JSON object which is sent to the Ubidots out node.
Configure the Ubidots-out node
Here you will be asked to enter your Ubidots token and the device label that will be created/updated in your account every time there's a new value coming from the PLC.
Check the results on your Ubidots account.