Skip to content
PSUT / IoTEngineering learning studio
WORKSPACE
Offline-first portalDr. Mohammad Alja’afreh
Embedded Systems StudioIoT Programming and ApplicationsExperimentsWorkspaces
ENGINEERING WORKSPACE
Home/Engineering Workspaces/MQTT and Node-RED
PSUT IoT Engineering StudioPrincess Sumaya University for Technology · Dr. Mohammad Alja’afreh
Integration center · real services
Supporting engineering workspace

MQTT & Node-RED

Two broker routes, one telemetry schema. Start with Python, then connect Wokwi. Dashboard preview below is a browser model; the actual Node-RED pages use received MQTT messages.

WOKWI / WSL INTEGRATION

Connect to actual MQTT telemetry

Run the supplied ESP32 greenhouse firmware and inspect received messages, live sensor readings and per-device history. No browser-generated readings are inserted into the live view.

Open Live Telemetry Studio →
Already installed everything in Setup? Skip the installer command for services that are installed and running; continue with their version/status checks and configuration. One-time installation guide →

Time-series deployment center

Follow the complete 16-stage walkthrough: install, configure tokens, test direct writes, start Telegraf, test MQTT, query stored data and provision Grafana.

Open Telegraf / InfluxDB / Grafana →

Choose your broker

⌂

Local Mosquitto

WSL 127.0.0.1:1884 · Wokwi host.wokwi.internal:1884. Loopback by default. No Internet needed after installation.

Open local dashboard ↗
☁

HiveMQ public test

broker.hivemq.com:1883 · Internet required. No authentication or confidentiality. Demo data only, random session label; never send credentials, personal IDs or real sensor data.

Open HiveMQ dashboard ↗ · WebSocket client ↗

Preview the telemetry pipeline

Install and configure — one time

01

Install local MQTT and Node-RED

Run in Ubuntu WSL, not Windows PowerShell. If the base setup was previously completed, this is safe to repeat. Node-RED Dashboard 2.0 is installed under your Linux user.

WSL · Bash
bash ~/psut-wsl/setup_wsl.sh --nodered
source ~/psut-wsl/activate.sh
systemctl is-active mosquitto nodered
ss -ltn | grep :1884
curl -fsS http://127.0.0.1:1880/ >/dev/null
✓ Expected: HTTP request succeeds (no output when redirected to /dev/null). Open the Node-RED editor separately.
Expected result for each action (5)
  1. bash ~/psut-wsl/setup_wsl.sh --noderedThe installer completes and returns to the prompt. Verify the selected services and run the toolkit self-test; package logs may vary.
  2. source ~/psut-wsl/activate.shThe toolkit virtual environment is selected in this terminal, usually with (.venv) in the prompt. Verify which python points into ~/psut-wsl/.venv.
  3. systemctl is-active mosquitto noderedAn active line is expected for each required running service; inactive/failed requires investigation.
  4. ss -ltn | grep :1884A listening TCP socket for port 1884 should appear if the local MQTT broker is running.
  5. curl -fsS http://127.0.0.1:1880/ >/dev/nullHTTP request succeeds (no output when redirected to /dev/null). Open the Node-RED editor separately.
Checkpoint Both services active; port 1884; HTTP success.
02

Generate profiles

Run either or both commands. Local uses fixed lab names; HiveMQ generates a random session once and reuses it. These files live in your WSL home, not in the Windows website folder.

WSL · Bash
python3 ~/psut-wsl/tools/mqtt_profile.py local
python3 ~/psut-wsl/tools/mqtt_profile.py hive
✓ Expected: The requested broker profile and matching Node-RED flow are generated under ~/.config/psut-wsl; use the same profile/session in all terminals.
Expected result for each action (2)
  1. python3 ~/psut-wsl/tools/mqtt_profile.py localThe requested broker profile and matching Node-RED flow are generated under ~/.config/psut-wsl; use the same profile/session in all terminals.
  2. python3 ~/psut-wsl/tools/mqtt_profile.py hiveThe requested broker profile and matching Node-RED flow are generated under ~/.config/psut-wsl; use the same profile/session in all terminals.
Checkpoint Printed broker settings, exact topics, absolute JSON flow files and dashboard URLs.
03

Open the generated flow file in Windows

In the SAME WSL terminal, open the configuration folder with Windows Explorer. Copy the desired flow JSON to Windows Downloads if needed.

WSL · Bash
cd ~/.config/psut-wsl
explorer.exe .
✓ Expected: Windows File Explorer opens the current Linux folder; no terminal output is normally required.
Expected result for each action (2)
  1. cd ~/.config/psut-wslNormally no output. pwd should show the requested directory. A missing path produces an error; do not continue until corrected.
  2. explorer.exe .Windows File Explorer opens the current Linux folder; no terminal output is normally required.
Checkpoint flow-local.json and flow-hive.json appear.
04

Import and deploy once per broker

In Windows open Node-RED editor. Menu ☰ → Import → select flow-local.json or flow-hive.json → Import → Deploy. You may install both: unique base paths /psut-local and /psut-hive. Do not import a second copy. For an update, delete the prior PSUT Studio flow and its unused ui-base/page/group/theme and MQTT config nodes in Configuration nodes, then import the replacement and Deploy. Remove the old Lab 13 tab if no longer used.

Checkpoint MQTT input node shows connected. Dashboard 2 palette has ui-template. No duplicate dashboard paths.
05

Verify installation

Run the offline checks and then local MQTT round-trip self-test.

WSL · Bash
source ~/psut-wsl/activate.sh
python3 ~/psut-wsl/tools/test_static.py
node ~/psut-wsl/tools/test_telemetry.js
bash ~/psut-wsl/tools/selftest.sh
✓ Expected: The toolkit reports checks for the installed components. Review any FAIL or unavailable optional service before continuing.
Expected result for each action (4)
  1. source ~/psut-wsl/activate.shThe toolkit virtual environment is selected in this terminal, usually with (.venv) in the prompt. Verify which python points into ~/psut-wsl/.venv.
  2. python3 ~/psut-wsl/tools/test_static.pyThe corresponding test program reports its checks and returns; investigate any failed assertion or error.
  3. node ~/psut-wsl/tools/test_telemetry.jsThe corresponding test program reports its checks and returns; investigate any failed assertion or error.
  4. bash ~/psut-wsl/tools/selftest.shThe toolkit reports checks for the installed components. Review any FAIL or unavailable optional service before continuing.
Checkpoint Tests pass; Core failures: 0. Optional services may be unavailable.

Live visualization — publish and verify

01

Terminal A — view traffic

Choose the same broker as the imported flow. Leave running.

WSL · Bash
source ~/psut-wsl/activate.sh
source ~/.config/psut-wsl/mqtt-local.env
mosquitto_sub -h "$MQTT_HOST" -p "$MQTT_PORT" -t "$MQTT_TOPIC" -q 1 -v
✓ Expected: The subscriber remains open. Once a matching publisher sends data, topic and JSON payload appear; an initially blank screen is normal.
Expected result for each action (3)
  1. source ~/psut-wsl/activate.shThe toolkit virtual environment is selected in this terminal, usually with (.venv) in the prompt. Verify which python points into ~/psut-wsl/.venv.
  2. source ~/.config/psut-wsl/mqtt-local.envThe local MQTT profile is loaded silently. Verify host 127.0.0.1, port 1884 and the matching topic in this shell.
  3. mosquitto_sub -h "$MQTT_HOST" -p "$MQTT_PORT" -t "$MQTT_TOPIC" -q 1 -vThe subscriber remains open. Once a matching publisher sends data, topic and JSON payload appear; an initially blank screen is normal.
Checkpoint Waiting for messages.
02

Terminal B — publish from Python

Use five labelled mock DHT22 samples.

WSL · Bash
source ~/psut-wsl/activate.sh
source ~/.config/psut-wsl/mqtt-local.env
cd ~/psut-wsl/labs/pi-practical
python -m labs.exp12.publisher --mock --count 5 --interval 2
✓ Expected: Five acknowledged publications are expected with --count 5; verify unique received records separately.
Expected result for each action (4)
  1. source ~/psut-wsl/activate.shThe toolkit virtual environment is selected in this terminal, usually with (.venv) in the prompt. Verify which python points into ~/psut-wsl/.venv.
  2. source ~/.config/psut-wsl/mqtt-local.envThe local MQTT profile is loaded silently. Verify host 127.0.0.1, port 1884 and the matching topic in this shell.
  3. cd ~/psut-wsl/labs/pi-practicalNormally no output. pwd should show the requested directory. A missing path produces an error; do not continue until corrected.
  4. python -m labs.exp12.publisher --mock --count 5 --interval 2Five acknowledged publications are expected with --count 5; verify unique received records separately.
Checkpoint Five messages acknowledged and visible in subscriber.
03

View actual Node-RED dashboard

Open local or HiveMQ. Select the device from the dropdown. Source is self-reported; chart history is in memory.

Checkpoint Temperature and humidity tiles, trend chart, latest 10 rows. No soil for DHT22.
04

Terminal C — greenhouse fields

Same profile; use 5 samples before Wokwi.

WSL · Bash
source ~/psut-wsl/activate.sh
source ~/.config/psut-wsl/mqtt-local.env
cd ~/psut-wsl/labs/python/lab43
MESSAGES=5 PERIOD=2 python device_simulator.py
✓ Expected: Five telemetry messages are published at the configured interval. Confirm their reception in the matching subscriber and dashboard.
Expected result for each action (4)
  1. source ~/psut-wsl/activate.shThe toolkit virtual environment is selected in this terminal, usually with (.venv) in the prompt. Verify which python points into ~/psut-wsl/.venv.
  2. source ~/.config/psut-wsl/mqtt-local.envThe local MQTT profile is loaded silently. Verify host 127.0.0.1, port 1884 and the matching topic in this shell.
  3. cd ~/psut-wsl/labs/python/lab43Normally no output. pwd should show the requested directory. A missing path produces an error; do not continue until corrected.
  4. MESSAGES=5 PERIOD=2 python device_simulator.pyFive telemetry messages are published at the configured interval. Confirm their reception in the matching subscriber and dashboard.
Checkpoint Select python-sim in dashboard, see soil moisture too.
05

Wokwi integration

Proceed to Python Lab 43. It describes exact VS Code firmware settings, Windows forwarding, build and sensor controls. Optionally use Telegraf/InfluxDB and Grafana in parallel.

Checkpoint ESP32 readings appear under esp32-01. Node-RED works without InfluxDB.
HiveMQ browser client: open the linked WebSocket client, use its public broker settings (host broker.hivemq.com, secure WebSocket port 8884, path /mqtt if configurable), connect using a random client ID, subscribe to the exact MQTT_TOPIC printed by the profile. This is separate from the TCP port 1883 used by Python and Wokwi. Do not enter private credentials.

References & boundaries

FlowFuse Dashboard 2.0 · HiveMQ public broker · Wokwi VS Code configuration. Public data can be forged, lost or duplicated; no control commands go to public topics. Node-RED should remain local; do not expose its editor to the Internet.

Download local flow JSON (same as generated local file).

Local editor access

Node-RED has no editor login by default. Keep the editor on your own workstation. If this is a shared machine, configure adminAuth and dashboard access before use; do not expose port 1880 to untrusted networks. For a local-only listener, edit ~/.node-red/settings.js, set the existing uiHost property to "127.0.0.1", then restart Node-RED. Do not add a duplicate property.

ThingSpeak integration center

Use the dedicated setup, upload, readback and Node-RED walkthrough.

Open ThingSpeak Cloud Studio →

Integrated IoT System Studio

Follow the complete telemetry pipeline, compare live and stored evidence, and investigate controlled failures.

Open integrated system workbench →

Connected IoT evidence replay

Load psut-stack-evidence.json from the notebook or inspect packaged local test evidence. Playback displays previously recorded software observations, not a live broker or physical measurement.

Choose an evidence record.

Virtual sensorTransportStored recordsFan stateTemperature axis

No valid record