OPC-UA
OPC-UA (OLE for Process Control - Unified Architecture, IEC 62541) is a standard communication protocol in industrial automation. Nearly every SCADA / middleware product — Kepware, Matrikon, Prosys, Ignition and others — provides OPC-UA server functionality.
Most PLCs do not have built-in OPC-UA server functionality, so PLC values are typically exposed over OPC-UA through gateway software such as Kepware; this gateway then connects to that OPC-UA server to retrieve the values.
The OPC-UA client in this gateway supports up to OPC UA 1.04 (IEC 62541:2020) — based on the Eclipse Milo 0.6.16 SDK.
- Transport: opc.tcp:// (UA Binary encoding)
- Security: standard policies such as None / Basic256Sha256 / Aes128_Sha256_RsaOaep / Aes256_Sha256_RsaPss
- User token: Anonymous / UserName+Password / X.509 Certificate
- Subscription: the gateway uses polling (
timecycleinterval) — UA MonitoredItem subscriptions are not used
Registration form fields
| Field | What to enter | Example |
|---|---|---|
| IP address | IP of the OPC-UA server PC | 192.168.0.40 |
| Port | OPC-UA server port | 49320 (Kepware default) / 4840 (standard) |
| User | User ID registered on the OPC-UA server | kopens (varies by server) |
| Password | Password for that user | *** |
| Server name (servername) | Server name at the end of the endpoint | (leave empty for Kepware) |
| Use Discovery | Whether to auto-discover the server's endpoints | Usually false. If it fails, try true |
| Use Subscription (subscription-enabled) | Server-push mode instead of polling | true when checked (efficient for large tag counts) |
| Publishing (publishing-interval) | Interval at which the server publishes data changes (ms) | 1000 (default) |
| Sampling (sampling-interval) | Interval at which the server samples values (ms) | 1000 (default) |
| Queue Size (queue-size) | Queue size for accumulated changed values (prevents notification loss) | 10 (default) |
If you leave both the User and Password fields empty, the connection is attempted anonymously. Anonymous access must be permitted on the server.
PLC address notation for tags
An OPC-UA tag address is normally in the following format, called a NodeId.
| Notation | Description |
|---|---|
ns=2;s=Channel1.Device1.Tag1 | namespace 2, string identifier — the most common form in Kepware |
ns=2;i=1234 | namespace 2, numeric identifier |
ns=3;g=09087e75-8e5e-499b-954f-f2a8624db28a | GUID type |
ns=is the namespace number. Usually2.- After
s=comes a path in the form "Channel.Device.Tag" (exactly as created in Kepware).
How do you find the NodeId
- PLC vendor / Kepware vendor manuals often include a mapping table.
- Connect directly with a free OPC-UA client such as UA Expert and right-click a node in the tree to copy its NodeId.
- Kepware's own OPC Quick Client tool can do the same.
Kepware quick setup
The procedure below is based on Kepware, a commonly used combination.
- Kepware Server → Project → add a channel (e.g.
Simulator) - Add a device (e.g.
Simulator) → model =16 Bit Device - Add a tag → name
Sine1, typeFloat, scan rate100ms - In Project Properties → OPC UA → Server Endpoint, enable port
49320 - Enable anonymous access or a user account
In this gateway's registration form:
| Field | Value |
|---|---|
| IP | IP of the Kepware server PC |
| Port | 49320 |
| User/Password | The account created above (leave empty if anonymous) |
| Tag PLC address | ns=2;s=Simulator.Simulator.Sine1 |
Common problems and solutions
| Symptom / message | Possible cause | Solution |
|---|---|---|
| "Connection refused" / no connection | OPC-UA server is down or the port is blocked | Check that the OPC-UA server is running and that the IP/port are correct |
| "User access denied" | Wrong user/password, or anonymous access not allowed on the server | Register the user on the server or allow anonymous access |
| "Security checks failed" | Server security policy mismatch | Set the server security policy to "None" or "Basic256Sha256" |
Connects, but the value is always 0 or null | Typo in the tag NodeId, or a different namespace number | Verify with UA Expert or similar that the same NodeId actually works |
| Repeatedly disconnects and reconnects | Unstable network, or load on the server PC | Inspect server PC resources / cabling / switches |
Commonly used data types
| PLC value | Data type | Type modifier | PLC address example |
|---|---|---|---|
| On/off | Boolean | (empty) | ns=2;s=Pump.Status |
| Integer | Integer | (empty) | ns=2;s=Counter |
| Large integer | Long | (empty) | ns=2;s=Total |
| Float (32-bit) | Float | (empty) | ns=2;s=Pressure |
| Float (64-bit, high precision) | Double | (empty) | ns=2;s=PrecisionTemp |
| String | String | (empty) | ns=2;s=Recipe.Name |
For OPC-UA, the format field is normally left empty (the server reports the data type).
More detailed examples / automated registration
To register automatically via script or API, see the OPC-UA examples on the Advanced — REST API page.