OPC UA Connector
Overview
Section titled “Overview”The OPC UA (Open Platform Communications Unified Architecture) connector enables communication with OPC UA servers, the industry-standard protocol for industrial automation and data exchange.
Connector Types:
OpcuaReader- Read data from OPC UA serversOpcuaWriter- Write data to OPC UA servers
Features
Section titled “Features”- ✅ Industry-standard protocol for industrial automation
- ✅ Multiple authentication methods (Anonymous, Basic, Certificate)
- ✅ Security modes (None, Sign, SignAndEncrypt)
- ✅ Configurable polling rates
- ✅ Support for complex node structures
- ✅ Both read and write operations
Basic Configuration
Section titled “Basic Configuration”OPC UA Reader
Section titled “OPC UA Reader”{ "type": "OpcuaReader", "config": { "endpoint": "opc.tcp://localhost:4840", "pollingRate": 1000 }, "variables": [ { "key": "temperature", "nodeId": "ns=1;s=Temperature" }, { "key": "pressure", "nodeId": "ns=1;s=Pressure" } ]}{ "type": "OpcuaReader", "config": { "endpoint": "opc.tcp://localhost:4840", "pollingRate": 1000, "auth": { "mode": "Basic", "username": "opcuser", "password": "opcpassword" } }, "variables": [ { "key": "temperature", "nodeId": "ns=1;s=Temperature" } ]}{ "type": "OpcuaReader", "config": { "endpoint": "opc.tcp://localhost:4840", "pollingRate": 1000, "auth": { "authCertificateFile": { "mode": "DirectPath", "fileName": "certificate.pem", "path": "/path/to/certificate.pem" }, "authKeyFile": { "mode": "DirectPath", "fileName": "key.pem", "path": "/path/to/key.pem" } }, "security": { "mode": "SignAndEncrypt", "policy": "Basic256Sha256" } }, "variables": [ { "key": "temperature", "nodeId": "ns=1;s=Temperature" } ]}OPC UA Writer
Section titled “OPC UA Writer”{ "type": "OpcuaWriter", "config": { "endpoint": "opc.tcp://localhost:4840", "auth": { "mode": "Basic", "username": "opcuser", "password": "opcpassword" } }, "variables": [ { "key": "setpoint", "nodeId": "ns=1;s=Setpoint" }, { "key": "control_mode", "nodeId": "ns=1;s=ControlMode" } ]}Configuration Parameters
Section titled “Configuration Parameters”Endpoint
Section titled “Endpoint”The OPC UA server endpoint URL.
{ "endpoint": "opc.tcp://192.168.1.100:4840"}Format: opc.tcp://[host]:[port][/path]
Polling Rate
Section titled “Polling Rate”For readers, the interval in milliseconds between data reads.
{ "pollingRate": 1000 // Read every 1 second}Recommended values:
- Fast: 100-500ms
- Normal: 1000ms (1 second)
- Slow: 5000ms (5 seconds)
Authentication
Section titled “Authentication”Anonymous (Default)
Section titled “Anonymous (Default)”No authentication required:
{ // No auth field needed}Basic Authentication
Section titled “Basic Authentication”Username and password:
{ "auth": { "mode": "Basic", "username": "your-username", "password": "your-password" }}Certificate Authentication
Section titled “Certificate Authentication”X.509 certificates:
{ "auth": { "authCertificateFile": { "mode": "DirectPath", "fileName": "client-cert.pem", "path": "/path/to/client-cert.pem" }, "authKeyFile": { "mode": "DirectPath", "fileName": "client-key.pem", "path": "/path/to/client-key.pem" } }}Security
Section titled “Security”Configure security mode and policy:
{ "security": { "mode": "SignAndEncrypt", "policy": "Basic256Sha256" }}Security Modes:
None- No security (default)Sign- Message signing onlySignAndEncrypt- Sign and encrypt messages
Security Policies:
NoneBasic128Rsa15Basic256Basic256Sha256(recommended)
Variables
Section titled “Variables”Variables define which OPC UA nodes to read from or write to.
Variable Structure
Section titled “Variable Structure”{ "key": "temperature", "nodeId": "ns=1;s=Temperature"}Fields:
key- The key name in the Meddle payloadnodeId- The OPC UA node identifier
Node ID Formats
Section titled “Node ID Formats”OPC UA supports several node ID formats:
{ "key": "sensor1", "nodeId": "ns=1;s=SensorName"}{ "key": "sensor2", "nodeId": "ns=1;i=1001"}{ "key": "sensor3", "nodeId": "ns=1;g=12345678-1234-1234-1234-123456789012"}{ "key": "sensor4", "nodeId": "ns=1;b=AQIDBAUGBwg="}Format: ns=[namespace];[type]=[identifier]
Where:
ns- Namespace index (0-65535)type- Node ID type:s- Stringi- Numericg- GUIDb- Opaque (Base64)
Data Flow
Section titled “Data Flow”Reader Data Flow
Section titled “Reader Data Flow”OPC UA Server → OpcuaReader → Meddle PayloadExample:
OPC UA nodes:
ns=1;s=Temperature= 25.5ns=1;s=Pressure= 101.3
Output payload:
{ "temperature": 25.5, "pressure": 101.3}Writer Data Flow
Section titled “Writer Data Flow”Meddle Payload → OpcuaWriter → OPC UA ServerExample:
Input payload:
{ "setpoint": 30.0, "mode": "auto"}Writes to:
ns=1;s=Setpoint← 30.0ns=1;s=Mode← “auto”
Common Use Cases
Section titled “Common Use Cases”1. Temperature Monitoring
Section titled “1. Temperature Monitoring”Read temperature sensors from a PLC:
{ "type": "OpcuaReader", "config": { "endpoint": "opc.tcp://plc.local:4840", "pollingRate": 1000 }, "variables": [ { "key": "zone1_temp", "nodeId": "ns=2;s=Zone1.Temperature" }, { "key": "zone2_temp", "nodeId": "ns=2;s=Zone2.Temperature" }, { "key": "ambient_temp", "nodeId": "ns=2;s=Ambient.Temperature" } ]}2. Process Control
Section titled “2. Process Control”Write setpoints to control a process:
{ "type": "OpcuaWriter", "config": { "endpoint": "opc.tcp://plc.local:4840", "auth": { "mode": "Basic", "username": "operator", "password": "secure123" } }, "variables": [ { "key": "temperature_setpoint", "nodeId": "ns=2;s=Control.TempSetpoint" }, { "key": "pressure_setpoint", "nodeId": "ns=2;s=Control.PressureSetpoint" } ]}3. Production Line Monitoring
Section titled “3. Production Line Monitoring”Monitor multiple machines:
{ "type": "OpcuaReader", "config": { "endpoint": "opc.tcp://scada.local:4840", "pollingRate": 500 }, "variables": [ { "key": "machine1_status", "nodeId": "ns=3;s=Machine1.Status" }, { "key": "machine1_speed", "nodeId": "ns=3;s=Machine1.Speed" }, { "key": "machine1_count", "nodeId": "ns=3;s=Machine1.ProductCount" }, { "key": "machine2_status", "nodeId": "ns=3;s=Machine2.Status" }, { "key": "machine2_speed", "nodeId": "ns=3;s=Machine2.Speed" } ]}Troubleshooting
Section titled “Troubleshooting”Connection Issues
Section titled “Connection Issues”Problem: Cannot connect to OPC UA server
Solutions:
- Verify the endpoint URL is correct
- Check network connectivity:
ping [server-ip] - Verify the port is open:
telnet [server-ip] 4840 - Check firewall rules
- Ensure the OPC UA server is running
Authentication Failures
Section titled “Authentication Failures”Problem: Authentication errors
Solutions:
- Verify username and password are correct
- Check if the user has appropriate permissions
- For certificate auth, ensure certificates are valid and not expired
- Verify certificate paths are correct
Node Not Found
Section titled “Node Not Found”Problem: “Node not found” errors
Solutions:
- Use an OPC UA client (like UaExpert) to browse the server
- Verify the namespace index is correct
- Check the node ID format matches the server’s format
- Ensure the node exists and is accessible
Security Policy Mismatch
Section titled “Security Policy Mismatch”Problem: Security policy errors
Solutions:
- Check which security policies the server supports
- Match the
security.policyto a supported policy - Ensure certificates are properly configured for encrypted connections
Performance Issues
Section titled “Performance Issues”Problem: Slow data updates or high CPU usage
Solutions:
- Increase
pollingRateto reduce frequency - Reduce the number of variables being read
- Use subscription-based reading if supported
- Check network latency
Best Practices
Section titled “Best Practices”1. Use Appropriate Polling Rates
Section titled “1. Use Appropriate Polling Rates”Don’t poll faster than necessary:
- Critical data: 100-500ms
- Normal monitoring: 1000ms
- Slow-changing values: 5000ms+
2. Secure Your Connections
Section titled “2. Secure Your Connections”Always use authentication and encryption in production:
{ "auth": { "mode": "Basic", "username": "user", "password": "pass" }, "security": { "mode": "SignAndEncrypt", "policy": "Basic256Sha256" }}3. Group Related Variables
Section titled “3. Group Related Variables”Keep related variables in the same connector for better organization:
{ "variables": [ // Temperature sensors {"key": "temp1", "nodeId": "ns=1;s=Temp1"}, {"key": "temp2", "nodeId": "ns=1;s=Temp2"}, // Pressure sensors {"key": "press1", "nodeId": "ns=1;s=Press1"}, {"key": "press2", "nodeId": "ns=1;s=Press2"} ]}4. Handle Connection Loss
Section titled “4. Handle Connection Loss”Meddle automatically handles connection loss and reconnection, but consider:
- Using a
Mergeconnector with timeout to handle missing data - Adding
Alertconnectors to notify on connection issues
5. Test with Anonymous First
Section titled “5. Test with Anonymous First”Start with anonymous authentication to verify connectivity, then add security:
- Test with no auth
- Add username/password
- Add encryption
- Add certificate authentication
Example Workflows
Section titled “Example Workflows”Complete Monitoring Workflow
Section titled “Complete Monitoring Workflow”OpcuaReader → Filter → Reshape → InfluxDb2Writer ↓ Trigger → Alert (email on high temp)- OpcuaReader: Read temperature and pressure
- Filter: Keep only relevant fields
- Reshape: Add metadata (location, unit)
- InfluxDb2Writer: Store in time-series database
- Trigger: Check for high temperature
- Alert: Send email if threshold exceeded
Related Connectors
Section titled “Related Connectors”- Modbus - Alternative industrial protocol
- Siemens S7 - Direct Siemens PLC communication
- Filter - Filter OPC UA data
- Trigger - Conditional logic on OPC UA data
Additional Resources
Section titled “Additional Resources”- OPC Foundation
- OPC UA Specification
- UaExpert - Free OPC UA client for testing