Explainer
Node-RED IO data MQTT setup: keep publish and control separate
Short answer
An IO-over-MQTT setup on an edge PC has three separate boundaries: the IO service that publishes values, the MQTT path that carries them, and the control path back to the device. Seeing values in Node-RED proves only the receive direction; you verify control at the device itself, and you troubleshoot from the first boundary where data stops.
On this page
- What are the three boundaries in an IO-over-MQTT setup?
- Which service publishes the IO values to the broker?
- Should you publish cyclically or only on change?
- Why does seeing values in Node-RED prove only half the setup?
- How do you verify the control path back to the device?
- Where does the local broker fit in this structure?
- Which boundary do you troubleshoot first when something fails?
- Questions asked
An IO-over-MQTT setup on an edge PC looks like one pipeline: values leave the device, travel through a broker, appear in Node-RED, and commands travel back. It is not one pipeline. It is three boundaries — the IO service that publishes values, the MQTT path that carries them, and the Node-RED control path back to the device — and each one can fail while the other two work. This article gives you the structure, the publish decision, and the verification order, so a green dashboard never passes for a working control path.
What are the three boundaries in an IO-over-MQTT setup? #
The setup splits into three boundaries: the IO service on the device that publishes process-image values to an MQTT broker, the MQTT path from that service to your subscribers, and the control path from Node-RED back to the device's outputs. On the Revolution Pi family the publishing service is RevPiPyLoad, which exports selected IO values to a broker; Node-RED then consumes those values and can publish commands that set outputs. A local Mosquitto broker on the same device or edge PC carries both directions. Every fault in this kind of system belongs to exactly one boundary, and naming the boundary is the whole troubleshooting job.
Which service publishes the IO values to the broker? #
The IO service does the publishing, not Node-RED: RevPiPyLoad reads the process image and publishes every value marked for export to the configured MQTT broker, using the connection settings in its own configuration file. Two consequences follow. First, your Node-RED flow is a consumer, so stopping it never stops the publish path — a subscriber problem and a publisher problem are different faults. Second, the export selection decides what exists on the broker at all: a value that is mapped in the process image but not marked for export never produces a message, which looks identical to a broken connection from the subscriber side. Before you debug anything else, confirm the service is running and the value you miss is marked for export.
Should you publish cyclically or only on change? #
For commissioning, publish cyclically at a 1 s interval; move slowly changing values to on-change publication once the path is proven. The reason is diagnosability: a cyclic value that stops arriving is unambiguous evidence of a dead path, while an on-change topic that stays silent could mean a dead path or simply a value that has not moved.
The cost of cyclic publishing is message volume, and it is easy to calculate. Take an illustrative example: 20 exported values published cyclically every 1000 ms. That is 1 message per second per value, so 20 × 1 = 20 messages per second, and 20 × 86,400 = 1,728,000 messages per day through the broker. If 3 of those values change on average once every 5 s and the other 17 are effectively constant, on-change publication gives 3 / 5 = 0.6 messages per second, about 51,840 per day — roughly 34 times less. A local broker handles either figure easily; the volume matters when the broker is remote, metered or shared, which is exactly when on-change wins.
Why does seeing values in Node-RED prove only half the setup? #
Values on screen verify exactly one direction: device to broker to Node-RED. That receive path can be fully green while the control path is completely dead, because the two directions share no logic — the control path depends on your Node-RED flow publishing the right command, the device-side service accepting it, and the output actually changing. A dashboard built from the receive path therefore proves the IO service is running, the export selection includes those values, and the broker connection works. It proves nothing about whether Node-RED can move an output. The same asymmetry is why we treat a missing-value symptom as a receive-path fault in the article on how to fix MQTT sensor data missing in Node-RED, and why a working dashboard is never the sign-off for a control project.
How do you verify the control path back to the device? #
You verify control with one deliberate test at the device itself: publish a command from Node-RED, then observe the physical output — an indicator, a relay, the input that reads it back — rather than any screen. Do this with the machine in a safe state and any output that could move equipment disabled at the actuator, because the first successful command is also the first untested one.
The test sequence is short. Confirm the flow's publish node shows a connected state on the broker, inject the command, and watch the output. If the output does not change, the fault is in one of three places: the flow published to the wrong topic or with the wrong payload, the device-side service rejected or ignored the message, or the service is not running. The documented tutorial for your installed system defines the exact topics and payload formats — take them from there, not from an example, because a command with the wrong payload does nothing and looks identical to a dead path.
Where does the local broker fit in this structure? #
The broker is the meeting point for both directions, and on a single-device setup it runs locally: RevPiPyLoad publishes to it, Node-RED subscribes and publishes commands to it, and nothing needs to leave the box. Keeping the broker local removes the network from the commissioning equation — a connection refused error then means the broker process, not a firewall or a route. When the same pattern runs on a separate edge PC, or the broker must serve other clients, the broker setup matters more, and the article on how to run a secure Mosquitto MQTT lab broker with Node-RED covers that build, including where TLS and access control enter. If a device elsewhere on the network cannot reach a broker on your PC, the causes are covered in the article on why a device cannot publish MQTT to a broker on your PC.
Which boundary do you troubleshoot first when something fails? #
Start at the first boundary where data or control stops, found by walking the three boundaries in signal order: service, broker path, Node-RED. In practice that means: check the IO service is running and the value is marked for export; check the service's broker connection and observe the topic with a plain subscriber before blaming any flow; then look at the Node-RED side. For the control direction, the order reverses — flow state first, then the device-side service, then the output. Record what you observed at each boundary (service state, connection result, message content, output response) before changing any configuration, because a fix applied without the failing boundary named is a coin flip. This walk fits as the data-path step inside the broader edge gateway commissioning sequence for plant data, which orders the same kind of checks for the whole gateway, from network through to the historian.
Questions asked
Do I need Node-RED to publish the IO values to the broker?
No. The IO service on the device publishes the exported values to the MQTT broker on its own; Node-RED is one consumer of those messages, not the publisher. That is exactly why the publish path and the Node-RED flow are verified separately: the values keep publishing even when your Node-RED flow is stopped or deleted.
Can the same broker carry both the published values and the control commands?
Yes. One broker, including a local one on the edge PC, can carry messages in both directions, and the documented setup uses exactly that arrangement. The two directions still need independent verification, and you keep the topics for published values and control commands distinct so a subscriber cannot mistake one for the other.
What decides whether a value gets published at all?
The export selection in the process image. Only values marked for export are published; a value that is mapped but not marked stays silent, which looks identical to a broken connection from the broker side. When one value is missing while its neighbours update, check that selection before touching the broker or the service.
Where do I get the exact topic names and payload formats?
From the step-by-step documentation for the installed system and service version, not from an example. The documented tutorial for this setup defines the topics and payloads; we do not reproduce them here because they differ between releases, and a control message with the wrong payload simply does nothing, which is indistinguishable from a dead path until you test at the device.