Skip to main content

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.

Supported spec / security

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 (timecycle interval) — UA MonitoredItem subscriptions are not used

Registration form fields

FieldWhat to enterExample
IP addressIP of the OPC-UA server PC192.168.0.40
PortOPC-UA server port49320 (Kepware default) / 4840 (standard)
UserUser ID registered on the OPC-UA serverkopens (varies by server)
PasswordPassword for that user***
Server name (servername)Server name at the end of the endpoint(leave empty for Kepware)
Use DiscoveryWhether to auto-discover the server's endpointsUsually false. If it fails, try true
Use Subscription (subscription-enabled)Server-push mode instead of pollingtrue 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.

NotationDescription
ns=2;s=Channel1.Device1.Tag1namespace 2, string identifier — the most common form in Kepware
ns=2;i=1234namespace 2, numeric identifier
ns=3;g=09087e75-8e5e-499b-954f-f2a8624db28aGUID type
  • ns= is the namespace number. Usually 2.
  • After s= comes a path in the form "Channel.Device.Tag" (exactly as created in Kepware).

How do you find the NodeId

  1. PLC vendor / Kepware vendor manuals often include a mapping table.
  2. Connect directly with a free OPC-UA client such as UA Expert and right-click a node in the tree to copy its NodeId.
  3. 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.

  1. Kepware Server → Project → add a channel (e.g. Simulator)
  2. Add a device (e.g. Simulator) → model = 16 Bit Device
  3. Add a tag → name Sine1, type Float, scan rate 100ms
  4. In Project Properties → OPC UA → Server Endpoint, enable port 49320
  5. Enable anonymous access or a user account

In this gateway's registration form:

FieldValue
IPIP of the Kepware server PC
Port49320
User/PasswordThe account created above (leave empty if anonymous)
Tag PLC addressns=2;s=Simulator.Simulator.Sine1

Common problems and solutions

Symptom / messagePossible causeSolution
"Connection refused" / no connectionOPC-UA server is down or the port is blockedCheck 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 serverRegister the user on the server or allow anonymous access
"Security checks failed"Server security policy mismatchSet the server security policy to "None" or "Basic256Sha256"
Connects, but the value is always 0 or nullTypo in the tag NodeId, or a different namespace numberVerify with UA Expert or similar that the same NodeId actually works
Repeatedly disconnects and reconnectsUnstable network, or load on the server PCInspect server PC resources / cabling / switches

Commonly used data types

PLC valueData typeType modifierPLC address example
On/offBoolean(empty)ns=2;s=Pump.Status
IntegerInteger(empty)ns=2;s=Counter
Large integerLong(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
StringString(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.