Blog / Connectivity
Connectivity · Guide

MES OPC UA Integration: Setup and Common Traps

OL By OEE Lab Editorial |Updated 2 November 2026 |7 min read
Short answer

The MES connects as an OPC UA client to a server in the PLC, gateway or SCADA. It browses the server's nodes, subscribes to run state, counters and fault codes, and maps each node to a machine field. Use SignAndEncrypt with a read-only user, check the sampling interval and queue size the server really grants, and keep deadband off fault codes and counters.

What OPC UA gives an MES

The OPC Foundation describes OPC UA as a service-oriented architecture that is not tied to one platform. It runs on anything from an embedded controller to cloud infrastructure, and each client and server is identified by an X.509 certificate.

In the classic setup, clients and servers interact, and a server exposes its data as nodes that a client can browse. The MES is the client, and it asks for what it needs.

The registered TCP port for the OPC UA connection protocol is 4840, though a server can be set up on another.

Your firewall request needs the real endpoint from the device, in the form opc.tcp://10.0.3.21:4840 (a made-up address).

The setup, in order

1
Find the endpoint
Get the address and port from the PLC, gateway or SCADA, and switch its OPC UA server on if the controls team agrees. Some controllers need a licence for it.
2
Exchange certificates
The MES and server must trust each other's certificate. Agree who manages expiry.
3
Browse with a test client
Find each node, read its value and data type, and watch it change.
4
Map nodes to fields
Write the table below and have the controls team sign it.
5
Create the subscription
Set sampling, publishing and queue values, then log what the server grants. Small PLCs can limit sessions and monitored items, so ask.
6
Check against the floor
Watch a shift and compare states and counts with what really happened.
Steps 1-3 use a test client on a laptop. Only then does the MES get involved.

Map nodes to MES fields

Node names on a PLC are often raw tag names. So the mapping table is where machine data gains meaning, and it is worth more care than the connection itself.

Node (made up)TypeMES fieldTreatment
ns=3;s=L3.Filler.RunningBooleanRun signalCombine with count to get state
ns=3;s=L3.Filler.GoodCountUInt32Good countStore the change, handle rollover
ns=3;s=L3.Filler.FaultCodeInt32Machine faultMap codes to reasons
ns=3;s=L3.Filler.RecipeStringProductLook up the ideal rate
A made-up example of the form. Which values to read, and why, is in PLC signals for OEE.

For the choice of signals see PLC signals for OEE. To turn them into run and stop, see machine state detection.

Some servers offer richer models than raw tags. The OPC Foundation publishes companion specifications such as Part 100 for devices, so ask whether your machine builder uses one.

The number after ns= is an index into the server's namespace table, and a server may change it between sessions. Store the namespace URI with each node, and look up the index after each connect.

Subscribe to live signals, read the rest

A client can read a node on demand, which suits a value needed once, such as a setting at order start. For live signals it creates monitored items in a subscription, and the server samples the values and sends the changes.

When nothing changes, the subscription sends a keep-alive message. So the MES can tell a quiet tag from a dead link.

Three settings decide what you really get, and they catch out many first projects.

  • Sampling interval: how often the server checks the value. It is a best effort target, and the server returns a revised value that can be slower than you asked. A request of -1 means use the publishing interval, and 0 means the fastest practical rate.
  • Publishing interval: how often the subscription sends what it has collected.
  • Queue size: how many changes each item holds between sends. With a size of 1, only the newest is kept, and the server may limit what you ask for.
Sampling 200 ms, publishing 1,000 ms
Changes per send: 1,000 / 200 = up to 5
Queue size 1: keeps 1, can lose 4
Queue size 5 or more, if granted: keeps them all
Hypothetical settings. A fault bit that flashes and clears inside one publishing interval can vanish with a queue of 1.

Log the granted values when the MES connects, along with any Overflow flag, which shows a queue lost values. A subscription that quietly got 1,000 ms sampling can miss a pulse of 100 ms however well you set it up.

A gateway adds one more limit. If it polls the PLC once a second, its OPC UA server cannot report a change any faster, whatever sampling you were granted.

Short pulses and counts

A "part made" pulse can fall between two samples, as any polled signal can. Read a running total, and take the change between values, because a total keeps its value until the next read.

A UInt32 total rolls over only after 4,294,967,295, but many PLC counters are smaller and reset at order change. The rollover math is the same whichever protocol carries the value.

Where deadband helps, and where it hurts

A data change filter can ignore small changes with a deadband. That suits a noisy temperature, where a change of 0.1 degree means nothing to you.

Absolute deadband applies only to number types, so it has no place on a Boolean state bit. Keep it off fault codes too, since each change matters there.

On a counter, a deadband of 10 only delays the update, and it can make the rate look jumpy.

Security settings to agree first

OPC UA defines three working security modes: None sends messages with no security, Sign protects integrity, and SignAndEncrypt adds confidentiality. Ask for SignAndEncrypt unless the device cannot do it.

  • Security policy: the endpoint also lists one, such as Basic256Sha256. Older ones such as Basic128Rsa15 are deprecated, so avoid them.
  • User: a dedicated user with read rights on the nodes you need, and no write rights.
  • Certificates: a named owner and an expiry date in someone's calendar. An expired certificate stops the data with no warning on the floor.
  • Network: keep the machine network apart from the office network, and open only the agreed path.

When the link drops

Sessions end, because of network faults, PLC restarts or a program download. The MES should reconnect by itself, and mark the gap as unknown rather than as running.

A subscription is built to survive a short gap, and the client can ask for missed messages with Republish. If the gap outlasts its lifetime, the server closes it and its monitored items, so the MES must be able to create them again.

A running total makes recovery simple, as the next value still includes parts made during the gap. For the state during the gap, a gateway that buffers with time stamps is the safer design, as IIoT gateway explains.

Check the clocks too. Each OPC UA value can carry a source time stamp, and it is only as good as the device clock behind it.

When client and server is not the right shape

OPC UA PubSub is the other model. Publishers send to middleware without knowing who subscribes, either over UDP on the network or through a broker such as MQTT.

It helps when many systems want the same data. For one MES reading a few machines, client and server is usually the simpler start.

Machines with no OPC UA server

Older controllers may offer only Modbus or a vendor protocol. A gateway can read those and offer them on as OPC UA or MQTT, and Modbus machine data covers the most common case.

If you are building your own connector, open62541 (MPL-2.0) and Eclipse Milo (EPL-2.0) are open source OPC UA implementations, both with commits on 2 November 2026 when we checked.

See it live in Fabrico

Once the signals are flowing, they still need meaning. Fabrico is a light MES for OEE: it takes stops, speed and counts live from PLCs or IoT sensors, with add-on AI cameras counting output where a machine has no usable signal, then operators tag the cause at the line. See how Fabrico connects machines.

What people ask next

Does an MES need OPC UA?

No. It is a common route, but Modbus, vendor protocols, MQTT from a gateway and external sensors can also work. Pick what the machine supports, as OEE data collection methods explains.

Is the MES an OPC UA client or server?

In most setups it is the client, reading from a server in the PLC, gateway or SCADA. The server holds the nodes, and the client browses and subscribes. One application can also act as both.

What sampling interval should I use for OEE?

Sample run state faster than your shortest stop, and 1 second is our suggested starting point. Log the value the server grants, as it may be slower than you asked. Stop threshold helps you decide what counts as a stop.

Can the MES write back to the PLC over OPC UA?

Technically yes, if the server and user rights allow it. Start read-only, and design any write as a separate handshake with the controls team. MES PLC integration shows the pattern.

Is OPC UA better than MQTT for an MES?

They do different jobs: OPC UA defines a data model and services, while MQTT is a light publish and subscribe transport that leaves topics and payloads to you. Many plants read OPC UA at the machine and publish MQTT from a gateway. See IIoT gateway.

See OEE per line and shift on your own machines

Fabrico is a light MES for OEE. It takes stops, speed and counts from PLCs or IoT sensors, with add-on AI cameras counting output where a machine has no usable signal, and operators tag the cause at the line.

Book a Fabrico demo

← More OEE Lab guides · MES PLC integration →

OEE essentials: OEE calculator · What is OEE · Six big losses · Availability · TEEP · Cost of downtime · OEE benchmark · Free OEE tracker · Free OEE software · How to track downtime · How to implement OEE · Light MES vs full MES