OPC UA is the communication backbone of modern Industry 4.0 — the protocol that bridges PLCs, SCADA systems, MES platforms, and cloud analytics into a unified information layer. If you're starting out in industrial IoT, this guide explains everything you need to understand OPC UA and connect your first server.
OPC UA (OPC Unified Architecture, standardised as IEC 62541) is a machine-to-machine communication protocol designed for industrial automation. It was developed by the OPC Foundation — a consortium of major automation vendors — to create a single, platform-independent standard that replaces the fragmented OPC Classic family (OPC DA, OPC HDA, OPC AE).
Key characteristics of OPC UA:
OPC UA uses TCP port 4840 by default. The endpoint URL format is: opc.tcp://hostname:4840/
| Characteristic | OPC Classic (DA/HDA/AE) | OPC UA |
|---|---|---|
| Transport | DCOM (Windows only) | TCP binary, HTTPS, WebSocket |
| Platform | Windows only | Any OS, PLC, cloud |
| Security | Windows DCOM security | Transport security + X.509 certificates |
| Firewall friendly | No (dynamic DCOM ports) | Yes (single configurable port) |
| Data model | Flat value/quality/timestamp | Rich: objects, variables, methods, events |
| Historical data | Separate OPC HDA protocol | Built-in Historical Access service |
OPC Classic is effectively legacy at this point — all new PLC generations (Siemens S7-1500 with TIA Portal, Beckhoff TwinCAT 3, Bosch Rexroth ctrlX, Rockwell FactoryTalk Optix) ship with OPC UA servers. DCOM-based connectivity continues to exist only for legacy equipment migration.
OPC UA is based on a client-server architecture:
The client-server relationship is initiated by the client — the server is always passive unless an explicit Publish/Subscribe extension (OPC UA PubSub) is used. For most manufacturing data collection use cases, the standard client-server model with subscriptions is the appropriate approach.
The OPC UA address space is a hierarchical tree of Nodes. Every piece of data exposed by a server is a Node. There are several Node classes:
Every Node has a Node ID — its unique identifier within the server. Node IDs take the form ns=2;s=ProductionCount where ns is the namespace index and s (or i for numeric, g for GUID) is the identifier.
# Example OPC UA Node IDs (Siemens S7-1500 style) ns=3;s="DB_Production"."ProductionCount" # Production count variable ns=3;s="DB_Production"."FaultCode" # Active fault code ns=3;s="DB_Production"."MachineState" # Current machine state (0=stopped, 1=running, etc.) ns=3;s="DB_Production"."CycleTimeActual" # Last cycle time in milliseconds
The Root, Objects, and Server nodes are standardised starting points in every OPC UA server. You browse from Objects downward to discover machine-specific variables.
Rather than polling data at fixed intervals, OPC UA Subscriptions are the efficient way to receive real-time machine data:
This approach is far more efficient than polling — the server only sends data when something changes, and the TCP connection is persistent so there's no per-request connection overhead.
A raw OPC UA server exposes vendor-specific node IDs (like ns=3;s="DB1"."Counter1"). Without knowing what the vendor's DB structure means, you can't write generic code against any machine.
This is where Information Models come in. An Information Model (sometimes called an OPC UA Companion Specification) defines a standardised address space structure for a domain:
If a machine implements a Companion Specification, a generic client can find and interpret its data without machine-specific programming. In practice, many machines partially implement specs — Semantic Mapping (like Shopfloor Copilot's YAML-based semantic engine) handles the translation from vendor-specific IDs to standardised signal names.
OPC UA has a three-layer security model:
None (development only) to Basic256Sha256 and Aes256_Sha256_RsaPss for production.SignAndEncrypt at the transport level with application certificates but skip user-level authentication for machine-to-machine connections. For IT-facing connections, full authentication at all three layers is recommended.
The easiest way to connect to an OPC UA server from Python is asyncua — a fully async Python OPC UA library:
pip install asyncua
import asyncio
from asyncua import Client
async def main():
url = "opc.tcp://192.168.1.100:4840/"
async with Client(url=url) as client:
# Browse the root Objects folder
objects = client.nodes.objects
children = await objects.get_children()
for child in children:
name = await child.read_browse_name()
print(f" {name}")
# Read a specific node by ID
node = client.get_node("ns=2;s=ProductionCount")
value = await node.read_value()
print(f"Production count: {value}")
# Subscribe to data changes
handler = SubscriptionHandler()
subscription = await client.create_subscription(500, handler)
nodes = [client.get_node("ns=2;s=ProductionCount")]
handle = await subscription.subscribe_data_change(nodes)
await asyncio.sleep(10) # Receive changes for 10 seconds
class SubscriptionHandler:
def datachange_notification(self, node, val, data):
print(f"Data change: {node} = {val}")
asyncio.run(main())
For a server with certificate authentication, pass certificate paths to the Client constructor. For anonymous connections to development servers, no credentials are required.
OPC UA (IEC 62541) is a platform-independent industrial communication protocol that enables secure, reliable data exchange between PLCs, SCADA systems, MES platforms, and cloud services. Developed by the OPC Foundation to replace the Windows-only OPC Classic family.
TCP port 4840 by default. The endpoint URL format is opc.tcp://hostname:4840/. Custom ports (e.g., 4850) are common when multiple servers exist on the same host.
A hierarchical tree of Nodes that the server exposes. Variable Nodes hold real-time data (PLC variables). Object Nodes group related variables. Every node has a unique Node ID (e.g., ns=2;s=ProductionCount).
OPC UA provides a rich two-way client-server model with built-in security, interoperable information models, and method calls. MQTT is a lightweight publish-subscribe protocol — simpler and better suited for IoT edge-to-cloud data streaming. They are complementary: OPC UA for shopfloor connectivity, MQTT for cloud transport. OPC UA PubSub extends OPC UA with MQTT transport.
See OPC UA in your factory → Shopfloor Copilot uses asyncua to connect to your PLC's OPC UA server and map signals to OEE, KPIs, and AI diagnostics automatically.
Try OPC Explorer →Related content: