OPC-UA Integration
Introduction
OPC-UA (Unified Architecture) is the standard industrial communication protocol for secure data exchange between PLCs, SCADA systems, and cloud systems. Eziwan allows you to access OPC-UA servers on your OT network from anywhere via a secure OpenVPN tunnel.
Prerequisites
On the automation side (OPC-UA server)
| PLC | OPC-UA Server | Minimum Firmware Version | System Requirements |
|---|---|---|---|
| Siemens S7-1500 | Native, built-in | FW 2.0 (2017) | Enable in TIA Portal |
| Siemens S7-1200 | Not available | — | Use Modbus TCP instead |
| B&R Automation | Native (ArOpc) | AR 4.34 | Enable in Automation Studio |
| Beckhoff TwinCAT | TF6100 (TwinCAT OPC UA Server) | TwinCAT 3.1.4020 | TF6100 license required |
| Phoenix Contact PLCnext | Integrated | FW 2020.0 | Enable via Web-Based Management |
| Schneider EcoStruxure | Native (M262/M580) | — | Enable in SoMachine |
Eziwan's Side
- Eziwan gateway with firmware version 2.3 or higher
- The gateway must be on the same Ethernet network as the OPC-UA controller, or able to connect to it (same VLAN, no firewall blocking port 4840)
- Default OPC-UA port: TCP 4840
Architecture: Access via a VPN tunnel
Remote OPC-UA access via Eziwan follows this procedure:
The Eziwan gateway acts as an OPC-UA proxy: it receives connections from remote clients via the OpenVPN tunnel and forwards them to the OPC-UA server on the local OT network. The remote client does not have direct access to the OT network.
TIA Portal Configuration: Enable the S7-1500 OPC-UA Server
Step 1: Open the CPU Properties
- In TIA Portal, double-click the S7-1500 CPU in the hardware view
- Go to the OPC UA tab
Step 2: Start the server
OPC UA
└── Server
[✓] Activate OPC UA server
Port: 4840
Max. sessions: 10
Session timeout: 10 000 ms
Security:
[✓] No security (Basic256Sha256 is also recommended in production)
[✓] Basic256Sha256 - SignAndEncrypt
Access control:
[ ] Allow anonymous access (disable in production)
[✓] Enable user access control
Step 3: Create a server interface
The server interface defines the variables exposed via OPC-UA:
OPC UA
└── Server interfaces
└── [New interface] → Nom: "Monitoring_Production"
└── Drag & Drop from the project:
DB10.Temperature → will be displayed as "Temperature"
DB10.Pressure → will be displayed as "Pressure"
DB10.ProductCount → will be exposed as "ProductCount"
DB10.Running → will be displayed as "Running"
Step 4: Create an OPC-UA User
OPC UA
└── Users
└── [Add user]
Username: eziwan_client
Password: MotDePasseStrong2026!
Role: Observer (read-only) or Operator (read/write)
Step 5: Compile and upload the hardware configuration
Important: Only the hardware configuration needs to be recompiled and uploaded. The user program (OB, FC, FB) remains unchanged.
Menu: Build → Build All (or Ctrl+B)
Check for errors in the hardware compilation only
Menu : Online → Download to device → Hardware configuration
Connecting from a Remote OPC-UA Client
Option 1: Prosys OPC UA Browser (free graphical interface)
- Download Prosys OPC UA Browser from prosysopc.com
- Launch the software
- Enter the URL:
opc.tcp://[IP_TUNNEL_EZIWAN]:4840 - Click "Connect"
- Select the security mode (None for testing, SignAndEncrypt for production)
- Navigate through the node tree to find your variables
Option 2: Python with asyncua
import asyncio
from asyncua import Client
from asyncua import ua
# Configuration de connexion
OPC_UA_URL = "opc.tcp://[IP_TUNNEL_EZIWAN]:4840"
USERNAME = "eziwan_client"
PASSWORD = "MotDePasseStrong2026!"
async def lire_donnees_production():
"""Connect and read production data via Eziwan."""
async with Client(url=OPC_UA_URL) as client:
# Username Authentication
client.set_user(USERNAME)
client.set_password(PASSWORD)
print(f"Connecté à {OPC_UA_URL}")
# Method 1: Direct access via NodeId (if known)
node_temp = client.get_node("ns=3;s=Monitoring_Production.Temperature")
temp = await node_temp.read_value()
print(f"Température : {temp} °C")
# Method 2: Navigating the Tree Structure
root = client.get_root_node()
objects = await root.get_child(["0:Objects"])
# List the child nodes
children = await objects.get_children()
for child in children:
name = await child.read_browse_name()
print(f"Nœud trouvé : {name.Name}")
# Method 3: Value-Triggered Subscription
handler = ChangementValeurHandler()
sub = await client.create_subscription(period=1000, handler=handler)
nodes_a_surveiller = [
client.get_node("ns=3;s=Monitoring_Production.Temperature"),
client.get_node("ns=3;s=Monitoring_Production.Pressure"),
client.get_node("ns=3;s=Monitoring_Production.Running"),
]
await sub.subscribe_data_change(nodes_a_surveiller)
print("Abonnement actif. Ctrl+C pour arrêter.")
try:
while True:
await asyncio.sleep(1)
except KeyboardInterrupt:
pass
finally:
await sub.delete()
class ChangementValeurHandler:
"""Gestionnaire des notifications OPC-UA."""
def datachange_notification(self, node, val, data):
print(f"[{data.monitored_item.Value.SourceTimestamp}] {node}: {val}")
asyncio.run(lire_donnees_production())
Option 3: Node-RED with node-opcua
[
{
"id": "opc-ua-input",
"type": "OpcUa-Client",
"endpoint": "opc.tcp://[IP_TUNNEL_EZIWAN]:4840",
"action": "subscribe",
"deadbandtype": "a",
"deadbandvalue": "1",
"time": "1",
"timeUnit": "s",
"certificate": "n",
"item": [
{"name": "Temperature", "nodeId": "ns=3;s=Monitoring_Production.Temperature"},
{"name": "Pressure", "nodeId": "ns=3;s=Monitoring_Production.Pressure"}
]
}
]
OPC-UA Security: Modes and Certificates
Available Security Modes
| Mode | Authentication | Encryption | Recommendation |
|---|---|---|---|
| None | None | None | For testing only, never in production |
| Sign | X.509 certificate | No | Medium |
| SignAndEncrypt | X.509 certificate | AES-256 | Required in production |
Supported Security Policies
- Basic128Rsa15: 1024-bit RSA (obsolete; do not use)
- Basic256: 2048-bit RSA + SHA-1 (acceptable)
- Basic256Sha256: 2048-bit RSA + SHA-256 (recommended)
- Aes128_Sha256_RsaOaep: AES-128 + SHA-256 (modern)
- Aes256_Sha256_RsaPss: AES-256 + SHA-256 (most secure)
Certificate Management via Eziwan
Eziwan automatically generates X.509 certificates for the OPC-UA connection:
- Eziwan Portal → Integrations → OPC-UA → Certificates
- Click "Generate a certificate"
- Export the certificate in
.derformat - Import it into the OPC-UA server’s trusted list (TIA Portal → OPC UA → Trusted Clients)
Troubleshooting
Problem 1: Connection Timeout
Symptom: ServiceResultException: BadTimeout or connection failure.
Causes and Solutions:
| Cause | Check | Solution |
|---|---|---|
| Port 4840 blocked | telnet [IP_OT] 4840 from the gateway | Open the port on the local OT firewall |
| OPC-UA server not enabled | Check in TIA Portal → OPC UA → Server | Enable and re-download the configuration |
| Incorrect gateway IP | Ping from gateway to PLC | Check gateway network configuration |
| Timeout too short | Increase client timeout | client.session_timeout = 30000 (asyncua) |
Problem 2: Rejected Certificates
Symptom: BadCertificateUntrusted or BadSecurityChecksFailed
Solutions:
- S7-1500 server side: TIA Portal → OPC UA → Trusted Clients → Add the Eziwan certificate
- Temporary mode: TIA Portal → OPC UA → Server → "Accept all certificates automatically" (disable after configuration)
- Regenerate the certificates: If the certificate has expired, regenerate it in the Eziwan portal
Problem 3: Nodes Not Found (BadNodeIdUnknown)
Symptom: BadNodeIdUnknown when reading a node.
Causes:
- The namespace (ns=X) is incorrect
- The server interface has not been created in TIA Portal
- The node name is misspelled
Solution: Use Prosys OPC UA Browser to navigate the actual tree structure and copy the exact NodeIDs.
Problem 4: Frequent Disconnections
Symptom: The client regularly disconnects, error BadConnectionClosed.
Solutions:
- Increase the
keepaliveIntervalon the client side - Check the stability of the network connection (OpenVPN keepalive configured)
- Verify that the
max_sessionslimit on the S7-1500 server has not been reached (TIA Portal → OPC UA → Server → Max. sessions)
Diagnostic Commands from the Gateway
From the Eziwan console (SSH or web interface → Terminal):
# Test connectivity to the OPC-UA server
nc -zv 192.168.20.10 4840
# Check the status of the OpenVPN tunnel
systemctl status openvpn-client@eziwan --no-pager
# OPC-UA connection logs (filtered for errors)
journalctl -u eziwan-opcua-client -n 50 --no-pager | grep -i error
Frequently Asked Questions
OPC-UA or Modbus: Which Should You Choose for Data Upload?
OPC-UA provides typing, units, node hierarchy, and certificate-based security; Modbus remains simpler for quick retrofits. For an S7-1500 or a recent SCADA system, choose OPC-UA; for an older, heterogeneous system, choose Modbus.
What is an OPC-UA node?
The server's information unit: a variable (measurement, setpoint), an object, or a method, identified by a NodeId within a namespace. The Eziwan client traverses the tree structure and subscribes to the selected nodes.
How do I manage OPC-UA certificates?
The client and server exchange X.509 certificates: the client's Eziwan certificate must be approved on the server side (TIA Portal, UaExpert), and an encryption policy must be selected (Basic256Sha256 recommended).
What devices does an OPC-UA server expose?
Recent PLCs (Siemens S7-1500/S7-1200, Schneider M580, Beckhoff), SCADA systems (WinCC, Ignition, AVEVA), and numerous high-end sensors and drives. For the rest of the system, the gateway collects data via Modbus.
Related Resources
- OPC UA to the Industrial Cloud — the solution page
- OPC UA and MQTT — combining rich data collection with lightweight data transport
- Comprehensive OPC UA Guide — the in-depth article
- Siemens S7 Compatibility — enabling the OPC UA server in TIA Portal
- Industrial Protocols — the OT protocols hub