IMD SolutionComputing LibraryShop main store

How-to

Bridge Revolution Pi I/O to MQTT with RevPiPyLoad

Edge computing and IIoT Published 5 min read By IMD Solution engineering team

Short answer

RevPiPyLoad already contains the MQTT bridge you want: install it, set the export flag in piCtory on each I/O MQTT must reach, point it at the broker, and set the interval to 15 seconds with send_on_event and write_outputs at 1. Inputs then publish every interval and on every change, one topic accepts output writes, and you write no logic. Topic names and payload formats come from the configuration on your unit.

On this page
  1. What RevPiPyLoad already does
  2. The settings that cover each requirement
  3. Install and configure the bridge
  4. Why the event flag matters
  5. Verify the bridge before you trust it
  6. Read the topic names from your own unit
  7. Questions asked

You do not need to write a forwarding program for this. The behavior you want — every configured input published on a fixed cycle, every change published the moment it happens, and a topic that writes the outputs — already exists in RevPiPyLoad, the Revolution Pi service that runs the Python control program and doubles as the server for MQTT, NetIO and PyControl. The whole configuration comes down to the piCtory export flag on each I/O, the broker address, an interval of 15 seconds, and send_on_event and write_outputs both set to 1. Below are the install command, the order of the steps, and the test that proves each of your three requirements.

What RevPiPyLoad already does #

RevPiPyLoad is the runtime service on the Revolution Pi: it executes the Python control program and serves NetIO, PyControl and MQTT. For this job you use only the MQTT role and leave the control program empty — that is what "no additional logic" looks like in practice. The device becomes the IoT gateway between its own I/O and the broker, the same architecture choice as PLC MQTT direct publishing versus an IoT gateway, except the gateway is already wired to the I/O.

MQTT itself — the OASIS publish/subscribe standard — never tells a device when to publish; the publisher decides. Here RevPiPyLoad decides: the interval setting is the heartbeat, the event setting is the change path. If the gateway hardware is not bought yet, the model trade is covered in Selecting a Revolution Pi Connect gateway for S7-1500 and Azure MQTT.

The settings that cover each requirement #

Your requirement Where it lives Value
All configured inputs published on a fixed cycle Interval in the RevPiPyLoad MQTT configuration 15 seconds
A change published immediately send_on_event 1
A topic that controls the outputs write_outputs 1
Only the chosen I/O exposed Export flag per I/O in piCtory set
No additional logic RevPiPyLoad's MQTT role itself no custom program

One rule scopes everything: RevPiPyLoad publishes only the I/O whose export flag is set in piCtory. The flag is your allow-list — set it on exactly the points MQTT must read or write, and everything else stays invisible to every subscriber.

Install and configure the bridge #

  1. Install the service on the Revolution Pi: sudo apt-get install revpipyload.
  2. Open the piCtory project and set the export flag on every input and output MQTT must reach, then apply the configuration to the device so the process image includes them.
  3. Open the MQTT configuration — through the graphical interface from a computer on the network, or in the configuration file on the RevPi itself — and enter the broker address, for example 192.168.1.50. Give the broker a fixed address first; whether a local MQTT broker needs a static IP address is decided here, and a DHCP address that drifts strands the bridge after a restart.
  4. Set the interval to 15 seconds and put send_on_event and write_outputs to 1.
  5. Restart RevPiPyLoad so it loads the new settings.

Broker placement is the one design choice left. Consumers on the plant network — a SCADA host, Node-RED — get a local broker, which keeps the data on the OT side. A cloud consumer also gets a local broker, with a local Mosquitto broker bridged to the cloud broker carrying the traffic out, instead of pointing the device itself at the internet.

Why the event flag matters #

The interval alone is a sampler, and samplers miss things. Without the event flag a change is reported at the next tick — up to a full interval late — and a pulse shorter than the interval can fall entirely between two ticks and never be published.

Worked example: a 2 s pulse on an exported input, arriving at a random time. With periodic publishing alone, the tick lands inside the pulse only 2 s / 15 s ≈ 0.13 of the time, so about 13 of every 100 such pulses are ever reported. With send_on_event at 1, the change is published when RevPiPyLoad detects it in the process image, and the pulse no longer depends on tick timing. The interval keeps running as the refresh that gives subscribers a heartbeat and restores values after a missed message. Volume stays modest: each exported point is reported 4 times a minute (60 s ÷ 15 s) and 240 times an hour (3600 s ÷ 15 s), so 20 exported points produce 20 × 240 = 4800 periodic value reports an hour, plus one message per detected change.

The detection-rate arithmetic for this flag is worked through in calculating the send_on_event detection rate. If a consumer needs exactly one message per rising edge rather than value refreshes, that trigger design is the subject of Publish one MQTT event when a PLC bit rises. Decision: leave the event flag at 1 permanently — it costs one message per real change and closes the gap the interval cannot.

Verify the bridge before you trust it #

  1. Connect an MQTT client to the broker and, on a test broker, subscribe to everything with # to see exactly what the bridge publishes — the topic names and payload as your installed version produces them.
  2. Watch the periodic messages: every exported input should reappear at the configured interval; check the spacing on the client's timestamps.
  3. Operate one exported input and confirm the new value publishes immediately, not at the next tick.
  4. Publish a valid value to the output-control topic and watch the output on the device.
  5. A point that never appears is almost always an unset export flag; fix it in piCtory and restart.

One caution belongs with step 4: with write_outputs at 1, every client that reaches the broker can switch real outputs. Run the output test with the machine in a safe state, keep the broker inside the OT network behind your normal access control, and never route a safety function through this path — e-stop and guard gating stay hardwired or in the safety controller.

Read the topic names from your own unit #

The topic names and payload encoding are defined by the RevPiPyLoad version on your unit; no naming convention is assumed here, so do not guess and do not copy names from another project. Take them from the MQTT configuration on the RevPi, or capture them once with the subscribe-to-everything test above, and put exactly those names into your subscribers. Repeat the capture after any RevPiPyLoad upgrade before production subscribers depend on it.

Questions asked

Do I need to write a Python program for this bridge?

No. RevPiPyLoad's MQTT role forwards exported I/O on its own; the Python control program it can run stays empty for this job. Add a program only later, if you want the device to calculate or condition values before publishing, because that is the point where you own logic again.

Can I keep some inputs and outputs off MQTT?

Yes. The export flag is the allow-list: only I/O flagged in piCtory are published, and you export only the outputs you want MQTT to control. Clear the flag on anything MQTT must not touch, apply the piCtory configuration and restart RevPiPyLoad; the point then disappears from the published data.

How much MQTT traffic will the bridge produce?

Multiply the number of exported points by 240: the interval yields four reports a minute per point, so eight exported points give 8 × 240 = 1920 periodic value reports an hour, plus one message per detected change while the event flag is on. Size cellular links and broker retention from that figure, measured on your own broker.

Why is one of my inputs missing from the published data?

Almost always an unset export flag: RevPiPyLoad publishes only flagged I/O. Set the flag in piCtory, apply the configuration to the device and restart RevPiPyLoad, then resubscribe. A point that never changes still appears in the periodic messages, so continued absence after the restart means the configuration was not applied, not that the input is quiet.

Keep reading

  • How-to

    How Geo SCADA publishes values to MQTT

    Geo SCADA Expert publishes outbound values as control writes to MQTT Text driver points: the topic lives in each point's Control settings and the control value becomes the payload, while the point's readback is irrelevant. Sparkplug payloads need the Sparkplug B driver. Data arriving from Node-RED proves only the inbound path.

    Edge computing and IIoT

  • Explainer

    Node-RED IO data MQTT setup: keep publish and control separate

    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.

    Edge computing and IIoT

  • How-to

    How to query InfluxDB over MQTT with a bridge flow

    InfluxDB does not answer queries over MQTT: it serves them over its HTTP API. Put a bridge on the edge PC — a Node-RED flow subscribed to a request topic — that maps a validated, bounded request to a query against the bucket and publishes the result to a separate response topic, so request and reply never loop.

    Edge computing and IIoT

Why MMP scratchpad values are missing from a Sparkplug payload