SDK · C

OPC UA in C

open62541 is the stack for embedded and constrained targets: portable C99, a single-file amalgamation you can drop into a build, and an EventLoop plugin architecture for porting to an RTOS. MPL-2.0, so linking it into a closed product is workable.

Projectopen62541
Version1.5.8
LicenceMPL 2.0
Installapt install libopen62541-dev, or vendor the single-file amalgamation

What to know before you start

  • MPL-2.0 file-level copyleft: your own files stay yours, modifications to theirs do not. Much easier to live with than LGPL for embedded work.
  • The single-file amalgamation is the pragmatic way to vendor it into an existing embedded build.
  • Crypto comes from mbedTLS or OpenSSL. Without one of them you get no security policies beyond None.
  • The Query service set and HTTPS are not implemented. If your design needs either, design differently.
  • An example server built with it has been certified for a standard server profile: note the pattern: the example is certified, not the library.
  • Commercial support from o6 Automation, who employ the core maintainers.

Recipes

The same twelve tasks, in this stack, pinned to the version above. Each one runs against a free public server.

TaskWhat it does
Connect to an OPC UA server in CCreate a client, apply the default configuration, then connect. open62541 returns a UA_StatusCode from everything: check it every
Browse an OPC UA address space in CBuild a UA_BrowseRequest with a filtered UA_BrowseDescription and walk the results. Filtering in the request matters more in C tha
Read a value from an OPC UA server in CThe high-level API gives you UA_Client_readValueAttribute for a bare value; use a full UA_ReadRequest when you need the status cod
Write a value to an OPC UA server in CBuild a variant with the scalar type the node declares and write it. Read the DataType attribute first rather than assuming, and c
Subscribe to data changes in CCreate a subscription, add a monitored item with a callback, then drive the client's event loop so notifications get processed. Th
Call an OPC UA method in CUA_Client_call takes the owning object, the method node and an input argument array, and hands back an output array you must free.
Set up OPC UA certificates in CLoad a DER certificate and private key, pass them plus your trust list to the encrypted client configuration helper, and set the A
Decode custom structures in Copen62541 can read a server's DataTypeDefinitions at runtime, but in C the pragmatic path for a known model is to generate types a
Read historical data in Copen62541 exposes historical reads through UA_Client_HistoryRead_raw with a callback per batch. Bound the window, check the server
Subscribe to alarms and events in CCreate an event monitored item on the Server object with an explicit select clause. In C you get the field values back as a positi
Publish with OPC UA PubSub in Copen62541 implements Part 14, which makes it a genuine option for deterministic publishing from an embedded target. Build a connec
Handle errors and reconnect in Copen62541's client keeps its own state machine. Call UA_Client_run_iterate in a loop, watch the channel and session state, and let

Last verified 7 September 2026 against OPC UA 1.05.07. Version read from the project release tags. OPC UA Connect is an educational resource and is not affiliated with the OPC Foundation.

Free download
OPC UA Troubleshooting & Integration Checklist
The field-tested checklist engineers use to diagnose certificates, ports and namespace problems fast, plus a Python (asyncua) client template.
Get the free checklist →
Free, no course, no login