Troubleshooting
Why Modbus variables do not appear on the OPC UA server
Short answer
The OPC UA server publishes controller runtime variables and never issues Modbus requests, so Modbus data stays invisible until the structure that receives it is selected as an OPC variable, the configuration is applied and the client rebrowses. This article gives the fix, the upstream checks and a worked register-offset example.

On this page
Yes, you can monitor Modbus values over OPC UA, and the fix is a single selection: mark the controller structure that receives the Modbus data as an OPC variable, apply the configuration, then reconnect the client and rebrowse the server. OPC UA never sends a Modbus request on its own; it publishes controller runtime data. Your local analog and digital points appear because they were selected for publication, while the variables your Modbus task fills were not. Once the containing structure is published, its registers, coils, holding data and inputs appear beneath it in the browse tree, and no separate OPC UA connection to any Modbus device is needed.
Where the request travels #
The two protocols do not pass through one another. Follow the data across four boundaries, each with its own failure signature:
- Field transaction. The controller's Modbus task exchanges a request and a response with the device. When this stage fails, the mapped member stays stale or carries a communication error status.
- Runtime mapping. The response bytes are written into members of a controller variable. When this stage fails, communication looks healthy but the intended member is wrong or never changes.
- Symbol publication. The OPC UA server exposes selected controller variables in its namespace. When this stage fails, the variable and its children are simply absent from the browse tree.
- Client access. The OPC UA client reads or subscribes to a node. When this stage fails, the node is visible but unreadable, or the session cannot be established.
Reading an OPC UA node never triggers a Modbus transaction. The client reads whatever the last completed poll left in the variable. How the Modbus side is built is a separate question, covered in which CODESYS module reads Modbus TCP I/O on an edge controller (article:which-codesys-module-reads-modbus-tcp-i-o-on-an-edge-controller).
Why local I/O appears while Modbus values do not #
Publication is per symbol. Working analog and digital I/O proves the server runs, the client connects and the selected symbols are exposed; it says nothing about the variables your Modbus task fills, because those were never added to the symbol configuration. The symptom therefore splits cleanly in two:
- The structure is missing from the browse tree. The fault is publication. Select the structure as an OPC variable, apply the configuration, and rebrowse.
- The structure is visible but a member is wrong or unchanging. Publication is fine. Move upstream to the runtime mapping and the Modbus exchange.
The same two-step logic applies across controllers: exposing Modbus coil addresses as named OPC UA symbols (article:exposing-modbus-coil-addresses-as-named-opc-ua-symbols) is the identical publication step done on a different platform.
Publish the containing structure #
Complete these steps in order and do not skip the runtime check:
- Finish the Modbus device configuration and map each needed value into the correct member of the controller structure.
- Watch the structure online and force a real change at the device. The matching member must move with the expected value and data interpretation before you touch anything on the OPC UA side.
- Open the symbol or variable configuration the controller's OPC UA server uses to build its namespace.
- Select the containing structure as an OPC variable. In the reported case this was a user-defined structure named
udtExample; select that whole structure, not only unrelated I/O points. - Apply the project to the controller with its normal deployment process so the running project is the revision you just edited.
- Reconnect the OPC UA client from a fresh session and refresh the namespace. Cached browse results hide newly published nodes.
- Expand the structure and read one coil member and one register member.
Keep the two roles distinct: the Modbus mapping decides which device value fills which member; the OPC publication decides whether an external client can discover and read that member. Fixing one never fixes the other.
Worked example: reading holding register 40009 at zero-based offset 8 #
This example traces one value end to end so you can see where a mismatch shows up.
Inputs, each with its source:
- The field device's register map lists the process value as holding register 40009, taken from the device's own documentation.
- Under the Modbus data-model convention, the first holding register carries the reference 40001, while the address inside a request is zero-based.
- Function code 03 reads holding registers, per the Modbus application protocol; Modbus TCP traffic runs on the registered port 502.
The rule in words: the address the controller must request equals the register reference minus the first reference of its block, because the request address counts with zero as the first register.
The arithmetic:
request offset = 40009 - 40001 = 8
The result: the controller's Modbus task must request holding-register offset 8 with function 03, and the member of the structure mapped to that response is the node the OPC UA client will read.
The decision it leads to: step the field value by a known amount and watch first the runtime member, then the OPC node. If the published member instead follows the register one position away, meaning offset 7 or 9, your mapping is off by one; repoint it and repeat the check. If the runtime member moves but the node does not follow within two completed poll cycles, the fault sits on the publication or client side. If neither moves, stop and fix the Modbus exchange first.
When the node exists but the value is stale #
A visible node with a frozen or wrong value sends you upstream. Check, in this order:
- The configured poll interval, response timeout and retry behavior in the controller's Modbus task.
- The destination address, unit identifier and quantity in the request against the device.
- The data type and byte order used to decode the register, since a swapped word order changes the value without breaking communication.
- The physical path. Over Ethernet: link state, cabling, the switch path and the interface status. Over serial: continuity, conductor assignment, termination, and matching baud rate, parity, data format and stop bits at both ends.
Only after the runtime member tracks the device does a stale OPC node point back at publication, the running project revision, client caching or the session itself.
Mistakes that hide or corrupt the values #
| Symptom | Likely boundary | Corrective check |
|---|---|---|
| Structure absent from the browse tree | OPC UA publication | Select the structure as an OPC variable, apply the project, rebrowse from a fresh session |
| Structure present but expected children missing | Symbol selection or structure definition | Confirm the selected symbol is the populated structure and the members belong to it |
| Children visible but never change | Modbus exchange or runtime mapping | Monitor the same members in the controller; check the transport, address and timing settings |
| Values change in the wrong members | Address or destination mapping | Compare each configured data type, request offset, quantity and destination member |
Work the table from the top. Publication faults are fixed in minutes; mapping and exchange faults need the online monitor before any OPC UA tool is opened.
Questions asked
Does an OPC UA read trigger a Modbus poll?
No. The OPC UA server hands the client the value stored in the controller variable at the moment of the read. Only the controller's Modbus task talks to the device, on its own poll interval, so the freshness of what the client sees is bounded by that interval plus the response timeout and any retries. A subscription tells the client when the stored value changes; it still never causes a Modbus transaction.
Do I need a separate OPC UA server or session per Modbus device?
No. One server holds one namespace, and every structure that receives Modbus data appears in it once published. Ten Modbus devices mapped into controller variables show up as nodes under the same server, and one client session reads all of them. The devices differ only in how the Modbus task is configured to reach them, not in how the client connects.
The structure is published but my client still does not show it. Why?
Most clients cache the browse tree of a server address space, so a node added after the session was opened stays hidden until you reconnect with a fresh session or rebuild the connection. Also confirm the controller is running the project revision you deployed, because a configuration applied to a project that is not the active one publishes nothing.
Should I publish each register member of the structure individually?
No. Selecting the containing structure publishes it with its children, so every register, coil, holding and input member mapped into it becomes browsable at once. Per-member selection is only worth doing when you must expose a strict subset and hide the rest, and it costs you a configuration entry for every value instead of one for the whole structure.

