November 11, 2025
November 11, 2025

OPC UA (Open Platform Communications Unified Architecture) is a standard communication protocol for industrial automation that enables secure data exchange between devices, controllers, and software systems. This tutorial demonstrates how to build an OPC UA server using Node-RED to expose machine and plant data in a structured, browsable format.
We'll create a complete OPC UA server that organizes industrial equipment data hierarchically, allowing any OPC UA client to discover and access the information.
This tutorial uses a demonstration station containing two main components:
Conveyor System: A material transport system with a stepper motor controlled by an Opto 22 industrial controller. The motor has two key properties—motor speed (measured in revolutions per second) and motor status (on or off).
Weighing Platform: A scale system with a load cell weight sensor that transmits weight measurements to the industrial controller via RS-232 serial communication.
The goal is to create an OPC UA server that represents this equipment structure, allowing OPC UA clients to browse through the hierarchy and access real-time data from both systems.
Before building the OPC UA server, map out the logical organization of your equipment and data points. For this demonstration station, the hierarchy looks like this:
This hierarchical structure mirrors how the physical equipment is organized, making it intuitive for operators and engineers to navigate.
Node-RED requires two packages for this implementation:
Opto 22 Node-RED Package: Provides nodes for reading data tags from Opto 22 industrial controllers. Install this package to access controller data.
IoT OPC UA Toolbox: A Node-RED package that includes nodes for creating OPC UA servers. You can find this package by searching for "node-red-contrib-opcua-iiot" in the Node-RED palette manager.
After installing both packages, you'll have access to the Opto 22 read nodes and the OPC UA IIoT Flex Server node in your Node-RED palette.
Create a flow that reads data from the industrial controller at regular intervals. Add three Opto 22 read nodes to collect:
Configure each node to poll the controller every three seconds. This provides regular updates without overloading the controller with read requests.
After reading the values, store them as global variables in Node-RED. This makes the data accessible to any node in your flow, including the OPC UA server node. Use function nodes to set global variables for motor speed, motor status, and weight.
Drag an OPC UA IIoT Flex Server node onto the Node-RED canvas. This node creates the actual OPC UA server that clients will connect to.
Double-click the node to open its configuration settings. Set the port number for your OPC UA server—port 4840 is the standard OPC UA port, though you can use alternatives like 54480 if needed.
The address space defines how data is organized and presented to OPC UA clients. Navigate to the Address Space tab in the server node configuration.
The address space is defined using JavaScript code. The package includes example code you can adapt for your structure. Here's the approach:
Start by performing necessary initializations and defining variables for your data points (motor speed, motor status, scale weight).
Build the folder structure starting from the root:
Create a root folder, then add a "Demo Station" folder inside it. Within Demo Station, create two folders: "Conveyor System" and "Weighing Platform."
Inside the Conveyor System folder, create a "Stepper Motor" folder to hold motor-related data points. Inside the Weighing Platform folder, create a "Load Cell" folder for weight sensor data.
After creating the folder structure, add nodes that hold actual machine values.
For each data point, specify:
Parent Folder: Where the node should appear in the hierarchyBrowse Name: The display name shown to clientsNode ID: A unique identifier for the nodeData Type: The variable type (integer, float, boolean, etc.)
Create two functions for each data point:
For motor speed, place it in the Stepper Motor folder, assign a browse name like "Motor Speed," set the data type to double or float, and create getter/setter functions that access the global motor speed variable.
Repeat this process for motor status (typically a boolean or integer) and weight (a float value).
The weight node goes in the Load Cell folder, while motor speed and status go in the Stepper Motor folder.
After configuring the address space, deploy your Node-RED flow. The OPC UA server starts running and listens for client connections on the specified port.
Your server is now active and exposing the structured equipment data to any OPC UA client on the network.
To verify your server works correctly, use an OPC UA client application. UA Expert is a popular free client available for download from Unified Automation.
Open UA Expert and add your server by providing its endpoint URL. The endpoint URL format is:
opc.tcp://[IP_ADDRESS]:[PORT]
For example: opc.tcp://192.168.1.100:54480
Click connect to establish communication with your Node-RED OPC UA server.
Once connected, expand the address space tree in UA Expert. You should see your complete folder hierarchy:
Navigate to Demo Station > Conveyor System > Stepper Motor to find Motor Speed and Motor Status. Navigate to Demo Station > Weighing Platform > Load Cell to find the Weight value.
Drag these data points to the Data Access View in UA Expert to monitor their values in real-time.
With the data points displayed in UA Expert, verify they update correctly:
Check that motor speed shows the correct value (for example, 0.5 revolutions per second when the motor is off). Motor status should display 0 for stopped or 1 for running.
The weight value should show the current reading from the load cell. Start your stepper motor and observe the motor status change from 0 to 1. As the motor runs and the conveyor moves material onto the weighing platform, you should see the weight value fluctuate.
Stop the motor and confirm the motor status returns to 0. These real-time changes confirm your OPC UA server is successfully reading controller data and exposing it to clients.
Creating OPC UA servers with Node-RED offers several advantages:
Standardized Access: Any OPC UA client can connect and read data without custom integration code
Hierarchical Organization: Data is structured logically, matching your physical equipment layout
Vendor Independence: OPC UA works across different manufacturers and platforms
Security Features: OPC UA supports encryption and authentication (though not configured in this basic example)
Easy Maintenance: Node-RED's visual programming makes updates and changes straightforward
This approach applies to many industrial scenarios:
Building an OPC UA server with Node-RED transforms how industrial equipment data is accessed and shared. By reading controller data, organizing it into a logical address space hierarchy, and exposing it through the standard OPC UA protocol, you create an interoperable data source that any OPC UA client can consume.
The process involves installing the necessary Node-RED packages, reading data from your industrial controllers, defining the address space structure with folders and data nodes, and deploying the server. Testing with an OPC UA client like UA Expert verifies the structure and confirms real-time data updates work correctly.
This approach is particularly valuable for integrating legacy equipment into modern industrial IoT architectures without replacing existing control systems.