IMD SolutionComputing LibraryShop main store

How-to

Bridge ScadaBR data to MQTT through Node-RED

Edge computing and IIoT Published 8 min read

Short answer

In this ScadaBR 1.2 design nothing on the ScadaBR side speaks MQTT, so Node-RED bridges both directions: the HTTP Sender passes point values as GET parameters to a /nodered HTTP input, a switch on msg.parts.key publishes them to topics BIN, INT and FLOAT, and a join feeds them back as GET query parameters to the HTTP Receiver at /ScadaBR/httpds. Match the BIN, INT and FLOAT names everywhere.

On this page
  1. What each side contributes
  2. Set up ScadaBR for sending and receiving
  3. Build the Node-RED flow
  4. Traffic budget for three points at a 30 s snapshot period
  5. Verify the loop in both directions
  6. When a value does not cross
  7. Close the wildcards before this leaves the bench
  8. Questions asked

In the ScadaBR 1.2 design below, nothing on the ScadaBR side speaks MQTT, so a Node-RED flow carries both directions. The ScadaBR HTTP Sender passes point values as GET parameters to a Node-RED HTTP input at /nodered; a switch node routes each value by its parameter name to MQTT topics BIN, INT and FLOAT; and three MQTT input nodes feed a join whose payload returns as GET query parameters to the ScadaBR HTTP Receiver at http://localhost:8080/ScadaBR/httpds. The names BIN, INT and FLOAT are the whole contract: publisher parameter names, switch rules, topic names and receiver parameterName fields must match exactly, case included. The sections below set up both ScadaBR sides, build the flow, size the message load the snapshot rate produces, and verify the loop end to end.

What each side contributes #

Two built-in ScadaBR pieces do the talking. The HTTP Sender publisher can point at any URL and send by GET or POST; the HTTP Receiver data source accepts values delivered by HTTP GET or POST, and each of its points declares the parameterName it reads from the request. Neither speaks MQTT, so Node-RED converts. The broker in this design is a plain MQTT service on localhost:1883 using protocol version 4 (MQTT 3.1.1), a 60 s keepalive and a clean session, with no TLS — a bench setup. Where that broker should live, inside a controller or on a separate box, is its own decision; the trade-offs sit in Running an MQTT broker in the PLC or on a separate device.

Direction ScadaBR piece Node-RED nodes Reaches
ScadaBR to MQTT HTTP Sender publisher, GET to http://localhost:1880/nodered HTTP in on /nodered, split, switch on msg.parts.key, MQTT out Topics BIN, INT, FLOAT
MQTT to ScadaBR HTTP Receiver data source at http://localhost:8080/ScadaBR/httpds MQTT in ×3, join in object mode keyed by msg.topic, HTTP request GET Receiver parameters BIN, INT, FLOAT

The exported project pairs six points so every signal exists on both sides:

Signal Sending point on virtual source DS_992547 Type Receiving point on DS_161663 Receiver parameterName
BIN DP_114918 binary DP_569236 BIN
INT DP_052981 numeric DP_058260 INT
FLOAT DP_600541 numeric DP_722462 FLOAT

All six points log on change, and the labels carry no hidden type difference: sending and receiving points for INT and FLOAT are declared numeric, and only BIN is binary. Note also that the broker keeps nothing — an MQTT broker routes messages rather than storing them, so the point log in ScadaBR is the only history in this design, the subject of Does an MQTT broker store historic data you can query.

Set up ScadaBR for sending and receiving #

  1. Create a virtual data source to simulate values — DS_992547 in the export, enabled, updating every 10 s. Add three settable points on it: the binary DP_114918 named BIN and the numeric DP_052981 and DP_600541 named INT and FLOAT. Set all three to log on change.
  2. Create the HTTP Receiver data source DS_161663 and enable it. Add one point per signal and set each point's parameterName to BIN, INT or FLOAT exactly as the table above shows — this field is what matches the incoming query parameter.
  3. Create an HTTP Sender publisher — PUB_190018 in the export. Set the destination to http://localhost:1880/nodered and leave the POST option off, so the request goes out as GET and matches the Node-RED input method.
  4. Add the three sending points to the publisher with parameter names BIN, INT and FLOAT, and turn timestamp inclusion off on each so the parameter carries the value alone.
  5. Enable snapshot sending with a snapshot period of 30 s and leave changes-only off, so every snapshot carries all three values whether or not they moved.
  6. Put all six points in one watch list — WL_757103 in the export — so sender and receiver sit side by side during commissioning.

Build the Node-RED flow #

  1. Add an HTTP in node, method GET, URL /nodered. A GET request delivers the query parameters as an object in msg.payload, one property per parameter.
  2. Wire the input through a split node, which breaks that object into one message per parameter and names each in msg.parts.key. Feed a switch node that compares msg.parts.key against the exact strings BIN, INT and FLOAT, one output per match.
  3. Give each switch output an MQTT out node with a fixed topic of the same name. The flow leaves QoS and retain unset on these nodes, so check the effective defaults on your Node-RED release rather than assuming they match the subscriptions.
  4. Complete the request with an HTTP response node, fed through the short template node in the export, so the ScadaBR GET finishes cleanly.
  5. For the return path, add three MQTT in nodes subscribing to BIN, INT and FLOAT on the same broker. In the exported flow the BIN subscription runs at QoS 0 and the INT and FLOAT subscriptions at QoS 2.
  6. Feed all three into one join node in object mode with msg.topic as the key, a count of 1 and accumulation on: every arriving message emits immediately as a payload object keyed by topic.
  7. Send that payload through an HTTP request node, method GET, URL http://localhost:8080/ScadaBR/httpds, set to append msg.payload as query parameters — the receiver reads each value from the parameter its point names.
  8. Configure the broker node for localhost, port 1883, clean session, no TLS, matching the plain local design.
  9. Drop debug nodes before the MQTT out nodes, after the join and after the HTTP request; they speed up commissioning, and you turn them off in steady operation.

Traffic budget for three points at a 30 s snapshot period #

Inputs. Three points leave ScadaBR — BIN, INT and FLOAT on publisher PUB_190018 — and the publisher sends a snapshot every 30 s with changes-only off. On the Node-RED side, the join emits after every single arriving message (count of 1) with accumulation on. The basis is one hour, 3,600 s.

Rule. With changes-only off, every snapshot carries every point, so publishes per hour = (3,600 s ÷ snapshot period) × point count. Inbound, the join emits on each message, and accumulation keeps every key it has seen, so after the first pass each GET re-sends all three parameters: point updates per hour = publishes per hour × point count.

Arithmetic. 3,600 s ÷ 30 s = 120 snapshots per hour. 120 snapshots × 3 points = 360 publishes per hour, which is 360 ÷ 60 = 6 publishes per minute. Inbound, those 360 messages give 360 GETs per hour, and with all three keys aboard each one writes 360 × 3 = 1,080 point updates per hour — 1,080 ÷ 60 = 18 updates per minute, 360 per point. The virtual source itself refreshes every 10 s, which is 300 refreshes per hour, but none of those intermediate values leave ScadaBR; only snapshots do.

Result. Three points cost 360 publishes and 1,080 receiver point updates per hour on a localhost HTTP link — light enough to leave running as built.

Decision. Keep the design at three points, but do not scale it unchanged: with accumulation on, receiver updates grow with the square of the point count — points × points × 120 per hour at this snapshot period. A buildout to 20 points would mean 20 × 20 × 120 = 48,000 updates per hour, about 800 per minute. Before scaling past a handful of points, switch the join's accumulation off so each GET carries only the parameter that just arrived — back to a linear 20 × 120 = 2,400 updates per hour — or move the publisher to changes-only.

Verify the loop in both directions #

  1. Deploy the flow and confirm the /nodered endpoint binds and the broker node reports a connection.
  2. Change DP_114918 on the virtual source. At the next snapshot, the debug node before the MQTT out nodes should show the switch selecting msg.parts.key = BIN and publishing on topic BIN.
  3. Publish a known value to each topic from any MQTT client — for example 1 to BIN, 42 to INT and 3.14 to FLOAT — and watch the join emit an object keyed by topic and the matching receiver point take the value.
  4. Open the ScadaBR events page: this publisher is set to raise result warnings, so a failed send appears there as an event instead of failing silently.
  5. Compare all six points in the watch list; sender and receiver values should agree within one snapshot period.
  6. Disable the debug nodes once commissioning is done.

When a value does not cross #

  • Nothing reaches MQTT. Check the method match first: the publisher must send GET because the Node-RED input listens for GET, and a POST to a GET-only input never fires. Then check the path /nodered and the exact msg.parts.key strings — a lowercase bin matches nothing.
  • MQTT never reaches ScadaBR. Match the topic against the receiver point's parameterName, confirm the join is in object mode keyed by msg.topic, and confirm the HTTP request node appends the payload as query parameters to the receiver URL.
  • Broker unreachable from containers. If Node-RED and ScadaBR sit in separate containers, localhost resolves inside the wrong one; point the broker and receiver nodes at the host name or address instead — the same pitfall as fixing a Telegraf MQTT client connecting to localhost in Docker.
  • Values arrive but look stale in time. Timestamps are excluded on every sending point, so ScadaBR stamps each arrival with its own clock; do not hunt for an end-to-end timestamp this design never sends.

Close the wildcards before this leaves the bench #

The exported receiver DS_161663 trusts every device ID and every source address — both whitelist fields are wildcards. Restrict both lists to the Node-RED host before enabling this receiver anywhere but an isolated bench, and keep the broker off the plant network while it runs without credentials or TLS; for a broker configured with certificates and per-topic access rules instead, follow the secure Mosquitto MQTT lab broker setup with Node-RED.

One more point belongs in the design rather than the caveats: the receiver points are settable, so anything that can publish to BIN, INT and FLOAT can set those points in ScadaBR. Keep points that command equipment off this return path, and keep the publish and control paths separate the way keeping publish and control separate in a Node-RED IO data MQTT setup lays out.

Questions asked

Why does ScadaBR not connect to the broker directly?

In this design ScadaBR talks only HTTP: an HTTP Sender publisher going out and an HTTP Receiver data source coming in, and neither speaks MQTT, so Node-RED does the conversion in both directions. If your ScadaBR build later gains a native MQTT client, retire the bridge, but keep the same parameter-name contract so the point pairs and topic names survive the change.

Where is the value history kept in this design?

In ScadaBR. All six points log on change and the exported project purges that log after one year. The broker holds nothing queryable, so for longer retention or plant-wide access to the values, add a historian on the MQTT side so the data lands there independently of the ScadaBR point log.

How do I add a fourth signal to the bridge?

Add one point on the virtual data source and one on the HTTP Receiver with the new parameterName, add the sending point to the HTTP Sender under the same parameter name, then extend the switch with one output and add one MQTT out and one MQTT in node on a topic of that name. The object-mode join picks up the new topic key by itself. Budget for it: each extra point adds 120 publishes per hour, and while accumulation stays on, receiver updates grow with the square of the point count.

Values refresh every 10 seconds in ScadaBR but MQTT only updates on the snapshot. Why?

They are two independent schedules. The 10 s period is the virtual source refreshing its simulated values inside ScadaBR; only the publisher snapshot clock sends data out, so intermediate values never reach MQTT. Enable changes-only on the publisher if you want only changed values to go out rather than a full set on every snapshot.

Keep reading

  • How-to

    Push ClearSCADA values to MQTT through an edge gateway

    ClearSCADA and Geo SCADA do not publish straight to an MQTT broker: the value travels from the SCADA server through an edge gateway to the broker as two independent client connections. Prove the SCADA read on one known point and the MQTT publish on a fixed test payload separately, join them only after both pass, and chase a login failure in the server's own web logs, never in the broker settings.

    Edge computing and IIoT

  • Comparison

    OPC UA vs MQTT Sparkplug from a controller to SCADA

    Pick OPC UA when the controller and the SCADA host share one plant LAN you control: the host subscribes inbound to the controller's browsable server. Pick MQTT Sparkplug B when the controller sits behind NAT, on cellular or at a remote site, or when several consumers need the same tags: outbound-only connections plus birth and death certificates give automatic tag discovery and stale detection.

    Edge computing and IIoT

  • How-to

    Bridging OPC UA PLC data to MQTT with an edge PC

    Keep the OPC UA server on the PLC side and give MQTT publishing its own role on a separate edge PC that acts as the OPC UA client and MQTT publisher. Commission the two links independently — first a verified tag read, then a verified subscriber message — and only then widen the tag set.

    Edge computing and IIoT