Manufacturers increasingly want to more tightly integrate the operations technology (OT) systems that control production with their informations technology systems to become more productive and flexible.
A typical scenario is the data transfer from these OT systems (like SCADA or PLC) to an OPC UA server, or in some cases to IT applications, where it can be analyzed and used for production control and optimization. The OT data is stored in OPC UA variables and contains production status, environment conditions, and additional information. It can be a problem, though, because while modern IT systems use protocols like http, websockets, MQTT (for IoT), and architectural styles (e.g. REST), OT systems use a variety of other protocols and fieldbus systems.
To access OPC UA variables, a protocol conversion is needed. If you want to try out the visualization of sensor data or build a more sophisticated solution (e.g. worker assistant) based on OPC UA, you can use this tutorial as a starting point. An OPC UA simulation server simulates an OPC UA server connected to a temperature sensor that is permanently generating random temperature values.
It is assumed that you have basic knowledge about manufacturing and are signed-up with the IBM Cloud. You may also want to read more detailed information about the OPC UA simulation server. We are using Node-RED which is an open source tool with a graphical user interface used to quickly connect internet of things applications. It comes with some default functionality (e.g. input nodes, output nodes), and is extensible.
Below are the steps to setup the OPC UA simulation server with the IBM IoT Platform. The OPC UA simulation server and the Node-RED gateway will be running locally.
OPC UA simulation server
First, we want to generate some data. In this case we are using the free PROSYS OPC UA Simulation Server, that runs on Windows, Linux, and MacOS.
- Download and install the PROSYS OPC UA Simulation Server.
Run the PROSYS OPC UA Simulation Server.
- Note the ocp.tcp address, e.g. opc.tcp://your-opc-ua-address:53530/OPCUA/SimulationServer
Select Options > Expert Mode to activate the expert mode.
- On the Simulation tab modify the simulation data that is needed.
I added an OPC UA object MIB (which is an option to group variables) and a variable temp that ranges from -2 to 2 (just because that is the default). On the Address Space tab you can see the attribute values of all simulated variables. We later need them as parameters in the Node-RED gateway, for example:
Watson IoT platform
The purpose of Watson IoT platform is twofold:
- It acts as an MQTT broker, receiving and forwarding MQTT events.
- It visualizes the events on a dashboard.
Create an IoT service and a device in that service that represents the Node-RED gateway sending events to the IoT service:
- Go to the IBM Cloud catalog
- Create a free (Lite plan) Internet of Things Platform service
- Note your Internet of Things Organization ID, e.g. lt9l36
- Create an Internet of Things device, see the Getting Started guide
Use descriptive names for the Device Type (e.g. OPCUA) and the Device ID (e.g. OPCUA1) and note them down. The Authentication Token can be generated automatically.
Now the IoT service is running and the device created, waiting for events to arrive. But before we create our visualization (temperature graph) we want to connect the OPC UA simulation server with the IoT service.
We use a simple Node-RED flow receiving messages from the OPC simulation server and sending them straight away to the IoT service.
Install the node-red-contrib-opcua and the node-red-contrib-ibm-watson-iot nodes via the Hamburger icon > Manage palette.
Now that the nodes are installed you can
Import the Node-RED flow, again using the Hamburger icon.
We need to configure our input and the output nodes:
The OPC UA client node OPC-UA connects to the OPC UA simulation server: Enter the endpoint =
- The Watson IoT node connects to our device: Enter Organization, Server-Name (youriotorgid.internetofthings.ibmcloud.com), Device Type, Device ID, Auth Token.
- In the Node-RED app open the inject node and modify the Topic, if needed. Topic is set to
ns=3;s=temp;datatype=Double, which represents the namespace, the variable name and type.
- When finished, click deploy to deploy the Node-RED flow
Now the Node-RED flow is running. The OPC UA node is pulling the current value of the OPC UA variable temp from the OPC UA simulation server in intervals of 60 seconds and the OPC UA messages should appear in the debug sidebar. The payload of the OPC-UA node is then transferred to the IoT platform.
Let’s head over to the Watson IoT platform and check if we can see the temperature values:
- Go to https://youriotorgid.internetofthings.ibmcloud.com/dashboard/devices/browse
- Click on your device (OPCUA1) and Recent Events.
Finally, we want to see the temperature values on the dashboard of the Watson IoT platform. For that we need to create a board and a card:
- Go to https://youriotorgid.internetofthings.ibmcloud.com/dashboard/boards and click Create New Board. Give it a name and click Next and then Submit.
- Select the board and click Add New Card.
- Click on Line chart and select the OPCUA1 device. Click on Next and then Connect new data set.
Enter the data set’s parameters:
Select the card size and click Next.
Now you can see the simulated temperature generated by the OPC UA server on the IoT platform.
This tutorial showed you how to connect an OPC UA simulation server to the Watson IoT platform for testing purposes. From this point you can explore more use cases, for example using the data in an application. It should be mentioned that although Node-RED can be used to quickly build prototypes, in real production scenarios, IBM App Connect for Manufacturing can be used as a more robust (or more readily manageable) gateway to tackle more massive deployments.