How-to
Bridge ScadaBR data to MQTT through Node-RED
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
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 #
- Create a virtual data source to simulate values —
DS_992547in the export, enabled, updating every 10 s. Add three settable points on it: the binaryDP_114918named BIN and the numericDP_052981andDP_600541named INT and FLOAT. Set all three to log on change. - Create the HTTP Receiver data source
DS_161663and enable it. Add one point per signal and set each point'sparameterNametoBIN,INTorFLOATexactly as the table above shows — this field is what matches the incoming query parameter. - Create an HTTP Sender publisher —
PUB_190018in the export. Set the destination tohttp://localhost:1880/noderedand leave the POST option off, so the request goes out as GET and matches the Node-RED input method. - Add the three sending points to the publisher with parameter names
BIN,INTandFLOAT, and turn timestamp inclusion off on each so the parameter carries the value alone. - 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.
- Put all six points in one watch list —
WL_757103in the export — so sender and receiver sit side by side during commissioning.
Build the Node-RED flow #
- Add an HTTP in node, method GET, URL
/nodered. A GET request delivers the query parameters as an object inmsg.payload, one property per parameter. - 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 comparesmsg.parts.keyagainst the exact stringsBIN,INTandFLOAT, one output per match. - 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.
- Complete the request with an HTTP response node, fed through the short template node in the export, so the ScadaBR GET finishes cleanly.
- For the return path, add three MQTT in nodes subscribing to
BIN,INTandFLOATon the same broker. In the exported flow the BIN subscription runs at QoS 0 and the INT and FLOAT subscriptions at QoS 2. - Feed all three into one join node in object mode with
msg.topicas the key, a count of 1 and accumulation on: every arriving message emits immediately as a payload object keyed by topic. - Send that payload through an HTTP request node, method GET, URL
http://localhost:8080/ScadaBR/httpds, set to appendmsg.payloadas query parameters — the receiver reads each value from the parameter its point names. - Configure the broker node for
localhost, port 1883, clean session, no TLS, matching the plain local design. - 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 #
- Deploy the flow and confirm the
/noderedendpoint binds and the broker node reports a connection. - Change
DP_114918on the virtual source. At the next snapshot, the debug node before the MQTT out nodes should show the switch selectingmsg.parts.key=BINand publishing on topicBIN. - Publish a known value to each topic from any MQTT client — for example 1 to
BIN, 42 toINTand 3.14 toFLOAT— and watch the join emit an object keyed by topic and the matching receiver point take the value. - 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.
- Compare all six points in the watch list; sender and receiver values should agree within one snapshot period.
- 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
/noderedand the exactmsg.parts.keystrings — a lowercasebinmatches nothing. - MQTT never reaches ScadaBR. Match the topic against the receiver point's
parameterName, confirm the join is in object mode keyed bymsg.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,
localhostresolves 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.