Synthetic Data — MQTT
The Demo Factory flow for MQTT publishes real-time JSON messages to four topics via Node-RED. This lets you test the MQTT data source in Pirivision against a real broker connection.
Published Topics
| Topic | Interval | Content |
|---|---|---|
fabrika/hat1/sicaklik |
2 s | Temperature (°C) |
fabrika/hat1/basinc |
2 s | Pressure (bar) |
fabrika/hat1/tank_seviye |
5 s | Tank fill level (%) |
fabrika/hat1/sayac |
1 s | Monotonically increasing production counter |
Every message is a JSON object with the following fields:
{ "ts": "2026-05-14T09:12:04.521Z", "value": 72.34, "unit": "°C", "makine_id": "M01", "hat_id": "HAT-1" }
Payload Generation Logic
A JavaScript function node runs inside Node-RED for each topic.
fabrika/hat1/sicaklik
70 °C base with a 30-second-period sine wave and random noise:
const t = Date.now() / 1000;
const base = 70;
const wave = 5 * Math.sin(t / 30); // ±5 °C wave, 30 s period
const jitter = (Math.random() - 0.5) * 1.5; // ±0.75 °C noise
const value = +(base + wave + jitter).toFixed(2);
msg.payload = {
ts: new Date().toISOString(),
value: value,
unit: "°C",
makine_id: "M01",
hat_id: "HAT-1"
};
fabrika/hat1/basinc
6.5 bar base with a 45-second-period sine wave and small noise:
const t = Date.now() / 1000;
const base = 6.5;
const wave = 0.4 * Math.sin(t / 45); // ±0.4 bar wave, 45 s period
const jitter = (Math.random() - 0.5) * 0.3; // ±0.15 bar noise
const value = +(base + wave + jitter).toFixed(2);
msg.payload = {
ts: new Date().toISOString(),
value: value,
unit: "bar",
makine_id: "M01",
hat_id: "HAT-1"
};
fabrika/hat1/tank_seviye
Oscillates between 25 % and 85 % on a 120-second period:
const t = Date.now() / 1000;
const value = +(25 + 60 * (Math.sin(t / 120) + 1) / 2).toFixed(2);
msg.payload = {
ts: new Date().toISOString(),
value: value, // 25..85 %
unit: "%",
tank_id: "T-01"
};
fabrika/hat1/sayac
Increments by one on every trigger; resets only when Node-RED restarts:
let n = context.get('n') || 0;
n = n + 1;
context.set('n', n);
msg.payload = {
ts: new Date().toISOString(),
sayac: n,
hat_id: "HAT-1"
};
Loading into Node-RED
- Open the Node-RED UI (
http://<server>:1880) in your browser. - Click the menu in the top-right corner → Import.
- Select the
demo_fabrika_mqtt.jsonfile → Import → Deploy.
Once the flow is active it connects to the broker and starts publishing messages to all four topics.
Adding to Pirivision
- Go to Port → New Data Source → MQTT.
- Enter the broker address and port.
- Click Save to store the connection.
Once saved, select this source in Compass to subscribe to any of the topics listed above.