AI & ML

From PLC to Cloud Dashboard: Building a Complete Data Pipeline with OPC UA, MQTT, Node-RED and a Time-Series Database

EDWartens Engineering Team
3 min read
From PLC to Cloud Dashboard: Building a Complete Data Pipeline with OPC UA, MQTT, Node-RED and a Time-Series Database

The project every automation engineer should build once

Nothing teaches IIoT like wiring the whole chain yourself: PLC, protocol, broker, database, dashboard. It takes a weekend with free software, and afterwards every vendor's platform is recognisable as the same chain with a logo. This is the build.

Using Node-RED as an OPC UA client locally, by CL Mechatronics

The stack

LayerToolCost
PLCS7-1200 or PLCSIM Advanced, or any PLC with OPC UAfree simulator
Edge logicNode-REDfree
MessagingMosquitto MQTT brokerfree
StorageInfluxDB or TimescaleDBfree
DashboardGrafana, or Node-RED Dashboardfree

All of it runs on one laptop or a Raspberry Pi; in production the same pieces run on an industrial PC and a server.

The pipeline, layer by layer
The pipeline, layer by layer

Step 1: expose the tags

Enable the OPC UA server on the PLC and mark the tags accessible: line speed, product count, motor current, machine state. In PLCSIM Advanced the server runs on the simulator. Test with UaExpert: if you can browse it there, Node-RED can read it.

Step 2: read with Node-RED

Install Node-RED, add the OPC UA client nodes, and build a flow: an OPC UA subscription node feeding a function node that builds a JSON object with tag name, value, timestamp and quality. The Node-RED IIoT course covers the nodes, the credentials and the security policies.

Step 3: publish with MQTT

Add an MQTT out node pointing at Mosquitto. Topic: plant/line1/filler/speed. For a real plant, publish Sparkplug B instead of raw JSON so every consumer understands the metrics; for the first build, JSON is fine.

Step 4: store

Subscribe with a second flow (or with Telegraf) and write into InfluxDB, one measurement per machine with tags for line and machine and fields for the values. Retention policy: raw for 90 days, downsampled averages for years.

Step 5: show

Point Grafana at the database. Build one dashboard: line speed as a time series, product count per hour as a bar chart, machine state as a state timeline, current with a threshold line. Add an alert rule that emails when the current is high for ten minutes. You now have a monitoring system many plants pay lakhs for.

Where each piece runs in production
Where each piece runs in production

Hardening it for a plant

  • TLS and credentials on OPC UA and MQTT, as in SCADA cybersecurity basics.
  • The edge PC in the control zone, the broker in the DMZ, the database and dashboard above it.
  • Store-and-forward on the edge, so a network outage does not lose data.
  • A clock synchronised everywhere, or the timestamps will lie.
An IIoT system with Node-RED, Python OPC UA and an S7-1500, by Basel Abdallah

From here

Add the anomaly detection script reading the database and publishing a health score; add a digital twin fed by the same stream. The pipeline is the foundation for both.

Frequently asked questions

Can I do this with an Allen-Bradley PLC? Yes, with the Node-RED EtherNet/IP nodes or a gateway; the rest of the chain is identical.

Should I use a cloud database instead? For learning, no. For a plant, only after the local pipeline works, and then the cloud is a second subscriber to the same broker.

How long does this take? A weekend with the simulator. The free course walks through it in order.

Start Your Engineering Career at EDWartens

Join as a Junior Engineer at Wartens Automation Pvt Ltd. Get hands-on PLC SCADA training, industry certifications, and a 100% Job Guarantee backed by a 100% refund policy.