Comparison
How Node-RED reads PLC data: OPC UA, MQTT or Modbus
Short answer
Pick the protocol by what the controller already serves, in this order: OPC UA if the PLC runtime exposes an OPC UA server, MQTT if the application can publish through an MQTT client library, Modbus TCP when only a register map exists. Node-RED has a client for all three; the deciding side is the PLC.

On this page
To feed PLC data into Node-RED over Ethernet there are three working paths: OPC UA, MQTT and Modbus TCP. Node-RED has a client for all three, so the choice is never made in Node-RED. It is made by the controller: use the richest interface the PLC runtime already exposes, in the order OPC UA, then MQTT, then Modbus TCP. This comparison gives the selection rule, the PLC-side requirement and the Node-RED package for each path, the limits that actually bite — request size, session counts, reconnect behavior — and a sizing example that shows why wire load almost never decides.
Decide on the PLC side, not in Node-RED #
Ask one question before configuring anything: what does the controller already serve? Work down the list and stop at the first yes.
- An OPC UA server in the runtime. Many modern controllers expose one — a CODESYS V3 runtime, for example, serves the application's variables through its built-in OPC UA server. If it is there, this is the path.
- An MQTT client the application can host. If there is no OPC UA server but the PLC project can run an MQTT client library, the controller becomes a publisher. This path adds one piece of infrastructure: a broker.
- A Modbus TCP server. When the controller only offers a register map, Node-RED polls and the PLC answers. It is the fallback, not a downgrade to take by default.
- None of the three over Ethernet. Then the decision moves to the wire between: a serial Modbus RTU link, or a gateway that exposes the controller as Modbus TCP or OPC UA.
The order is not taste. OPC UA (IEC 62541) carries typed, named variables with change-driven subscriptions and needs no extra infrastructure. MQTT (ISO/IEC 20922) decouples the controller from every consumer and pushes on events, at the cost of running a broker. Modbus TCP needs nothing but a register map, but the data is untyped 16-bit registers and something has to poll them.
The three paths at a glance #
Every row below is decided by the second column, which is what the PLC side must expose. Node-RED can be configured for all three; the controller cannot.
| Path | PLC side must expose | Node-RED side | Data flow | Best fit |
|---|---|---|---|---|
| OPC UA | An OPC UA server in the runtime, serving the application variables | An OPC UA client package such as node-red-contrib-iiot-opcua or node-red-contrib-opcua-client |
Session with subscriptions; server pushes changes | Typed data and change-driven updates without a broker |
| MQTT | An MQTT client library in the application — the MQTT Client SL library on CODESYS controllers, for example — plus a broker both sides reach | The built-in mqtt in and mqtt out nodes |
PLC publishes on change; Node-RED subscribes | Events, several consumers, plant-to-office decoupling |
| Modbus TCP | A Modbus TCP server with variables mapped to holding registers | The Modbus read nodes from the palette, on a polling schedule | Node-RED polls; server only answers | Controllers that expose registers only, periodic acquisition |
OPC UA: the controller runtime serves typed variables #
The OPC UA server lives inside the controller runtime and exposes the application's variables as a browsable address space; the Node-RED host is only a client that connects, reads and subscribes. That placement — server in the controller, reader at the edge — is the whole subject of where an OPC UA server sits when Python reads PLC data, and the answer is identical for Node-RED.
Two palette packages cover the client side. node-red-contrib-iiot-opcua is an OPC UA toolbox built on node-opcua, with connector nodes that hold the server details; install it from the palette or with npm install node-red-contrib-iiot-opcua. node-red-contrib-opcua-client keeps the endpoint, security policy and credentials in a shared opcua-config node, and its client nodes attach to that. Point either at the runtime's endpoint: for a controller at 192.168.1.50 on the default port the URL is opc.tcp://192.168.1.50:4840, 4840 being the OPC UA default unless the runtime was configured differently.
A subscription turns the flow from polling into push: the server sends a data-change notification when a monitored variable changes and keep-alives otherwise. Sessions, though, are state that lives on the controller. The runtime caps concurrent client sessions, so treat the controller as a scarce resource rather than a server for a dozen independent clients. Reconnection needs engineering too: a report on the CODESYS runtime discussion board describes a server that refused a new connection after five consecutive Ethernet cable disconnects, two minutes apart. That is a reported symptom on one runtime version, not a documented limit — so build reconnect logic into the flow and prove it with a cable pull on the runtime you deploy.
If the flow must serve data upward as well, Node-RED can run its own OPC UA server; deciding which nodes to expose on an edge gateway is covered in Node-RED OPC UA server node selection for edge gateways.
MQTT: the application publishes and a broker relays #
MQTT inverts the direction of the data. The PLC application publishes values; Node-RED subscribes. On CODESYS controllers the MQTT Client SL library supplies the client function blocks — publish to send, MQTTSubscribe to receive — and its setup on a CODESYS controller is walked through in Set up the MQTT Client SL library on a CODESYS controller.
MQTT requires a broker. Clients never talk to each other directly; each publishes to and subscribes from the broker, which relays by topic — how MQTT clients publish and subscribe through the broker is the mechanic that makes the architecture work. Run the broker where the consumers are: on the edge host for plant-local data, on a plant server when office systems subscribe as well, in a DMZ when the data crosses toward IT. If the broker lands on the edge host, that box becomes a permanent cabinet asset, and a fanless mini PC is the usual host for it.
On the Node-RED side nothing extra is needed: the built-in mqtt in node subscribes to the topic the PLC publishes. Use QoS 1 when a lost event matters — the broker acknowledges each publish at that level — and set the retained flag on the topic so a restarting Node-RED picks up the last published value immediately.
The reasons to choose this path are push and fan-out: values arrive when they change, and extra consumers subscribe without touching the controller. Publish one MQTT event when a PLC bit rises is that pattern in miniature. The cost is discipline: every consumer depends on the PLC publishing, and a silent publisher looks like healthy data unless the flow watches for it. When nothing arrives at all, the usual faults are broker address, port and credentials — Fix a PLC MQTT client that never reaches your broker walks that diagnosis.
Modbus TCP: Node-RED polls the register map #
Modbus TCP is the lowest common denominator: the controller runs a Modbus TCP server on the default port 502 with one unit ID, the application's variables are mapped to holding registers, and Node-RED reads them on a schedule with the Modbus nodes from the palette. Function 3, read holding registers, covers most process data, and the PLC does nothing but answer. Polling is the point: nothing new arrives until Node-RED asks.
Three limits decide whether the path holds up.
Request size first. One read-holding-registers request returns at most 125 registers, because the Modbus application protocol caps the response PDU at 253 bytes: subtract the function code and byte count and 251 bytes remain for data, and 251 divided by 2 gives 125.5, so 125 registers. A 200-register map is two sequential reads, which the polling node issues in turn.
Session count second. A controller-side Modbus TCP server accepts a limited number of simultaneous connections, and what happens when a second client needs the same server is covered in When one Modbus TCP server can serve two clients. On controller hardware the session count, not the byte count, is what runs out first.
Staleness third. With a fixed poll interval, the worst-case age of any value is one interval plus one round trip. Polling cannot deliver faster than its own schedule; if the process needs faster reaction, that is what the MQTT and OPC UA push paths are for.
Keep the flow read-only unless the application is designed for it: a Modbus write node from Node-RED can move a setpoint on a running line, and writes belong behind the controller's own interlocks.
And if the controller has no Ethernet service at all, the same register model exists on RS485 as Modbus RTU; Node-RED reads it through a serial port or a serial-to-Ethernet converter, and RS485 is not Modbus: reading a serial sensor from Node-RED shows the serial side end to end.
A sizing example: why wire load never decides #
Take an illustrative case and do the arithmetic; the inputs below are example values, not measurements. One controller and the Node-RED host share a switch. The flow reads 20 holding registers, and the Modbus poll runs every 500 ms.
Bytes per poll. A function 3 request is the 7-byte MBAP header plus function code, start address and quantity: 7 + 1 + 2 + 2 = 12 bytes. The response is the same header plus function code, a byte count and 2 bytes per register: 7 + 1 + 1 + (2 × 20) = 49 bytes. On the wire, Ethernet adds 38 bytes of fixed framing — preamble, addressing, checksum, inter-frame gap — and pads short payloads up to 46 bytes, so the request travels as 38 + 46 = 84 bytes and the response as 38 + 49 = 87 bytes: 171 bytes per poll.
Load. Two polls per second gives 171 × 2 = 342 bytes/s, which is 342 × 8 = 2,736 bit/s, about 2.7 kbit/s — roughly 36,000 times below a 100 Mbit/s link. The same data over MQTT, assuming one publish per change and a 300-byte payload of 20 named values, is about 400 bytes on the wire with protocol headers, and at one event per second that is 400 × 8 = 3,200 bit/s, about 3.2 kbit/s — the same order. OPC UA sits between them: a subscription sends data-change notifications only when a monitored variable changes, so steady-state load tracks the real change rate, with keep-alives in between.
The conclusion is the decision rule of this article in numbers: all three fit the wire with orders of magnitude to spare, so bandwidth does not select the protocol. What differs is staleness. The 500 ms poll can serve a value half a second old; the push paths deliver when the value changes, so a value's age drops to one network round trip. If the process tolerates half a second, Modbus TCP is enough; if not, the controller has to push.
The decision for each case #
- The runtime includes an OPC UA server — a CODESYS V3 controller, most modern platform runtimes: use OPC UA. Node-RED gets typed variables and change subscriptions; no broker, no register map to keep in sync.
- No OPC UA server, but the application can host an MQTT client: use MQTT. Stand up one broker, publish on change from the PLC, subscribe with the built-in
mqtt innode. Best when several consumers want the same events or the data crosses toward IT. - Only a register map: use Modbus TCP. Poll within the 125-register request limit, keep the session count inside what the server accepts, and accept staleness of one poll interval.
- No Ethernet service at all: Modbus RTU over the serial port, or a gateway that exposes the controller as Modbus TCP or OPC UA, then apply this same order to what the gateway serves.
In every case the decision sits on the PLC side. Inventory which server the controller already exposes, take the richest one, and configure Node-RED to match — never the other way around.
Questions asked
Do these three paths cover any PLC over Ethernet?
Only controllers that serve OPC UA, MQTT or Modbus TCP. Native protocols such as Siemens S7 or EtherNet/IP need their own Node-RED palette packages or a gateway that exposes the controller as Modbus TCP or OPC UA, and the same selection order then applies. Inventory which server the specific controller model exposes before configuring anything.
How old is a value when Node-RED polls at a fixed interval?
At worst, one poll interval plus one network round trip: with a 500 ms poll the data can be half a second old before the flow sees it. The push paths remove the interval term, because an MQTT publish or an OPC UA data-change notification arrives when the value changes, so the age drops to the round trip alone.
Can several clients read the same controller at once?
Each protocol spends the controller's client budget differently. A Modbus TCP server accepts a limited number of simultaneous connections, an OPC UA runtime caps concurrent sessions, and MQTT subscribers load only the broker rather than the PLC. If several Node-RED flows need the same data, read once and fan out inside Node-RED, or move to MQTT so the controller publishes once for every consumer.
Is the OPC UA server always included on the PLC side?
No. Some controller families ship the server in the runtime; others sell it as a licensed option or provide it through add-on packages, while the Node-RED palette packages are open source. Confirm in the controller vendor's runtime documentation that the server exists for your firmware before committing to the OPC UA path, because the client side only works if the server side is there.


