Free tech learning for everyone, from basics to pro

IoT LabsLabsIntermediate

Lab: Node-RED dashboard for sensor data

In short: Node-RED is a low-code tool that wires inputs, logic and outputs together in the browser. You connect it to your MQTT broker, show sensor readings on a dashboard and lock down the editor, which otherwise lets anyone run code on the host.

Aim and what you need

The aim is a live web dashboard of the temperature and humidity your ESP32 publishes. Node-RED represents logic as flows: boxes called nodes joined by wires. It is popular for IoT prototypes because you can connect MQTT, HTTP, databases and dashboards quickly.

  • A Raspberry Pi or Linux machine with Docker.
  • The secured broker from the MQTT TLS lab, with a dashboard user that can read lab/#, and the lab CA certificate.
  • A sensor publishing JSON such as {"t": 21.6, "h": 48} to lab/sensor1/env, or mosquitto_pub to fake it.
Data path in this labESP32publishes JSONMosquittoTLS brokermqtt inNode-RED nodeFunctiontidy valuesDashboardgauge andchart
Figure 1. Readings travel from the sensor through the broker into a Node-RED flow that feeds dashboard widgets.

Steps

  1. Start Node-RED with a named volume so flows survive restarts.
  2. Generate a password hash and add an adminAuth block to settings.js in the data volume, then restart.
  3. Open http://<pi-address>:1880, log in, and from Manage palette install the dashboard package (Dashboard 2.0 is published as @flowfuse/node-red-dashboard).
  4. Drag in an mqtt in node. Add a broker: host broker.lab.example, port 8883, enable TLS with your CA file, and the dashboard username and password. Topic lab/+/env, output: parsed JSON object.
  5. Add a change or function node that sets msg.payload to the temperature, then wire it to a gauge and a chart. Repeat for humidity.
  6. Deploy, then open the dashboard URL shown in the sidebar.
docker volume create node_red_data
docker run -d --name nodered --restart unless-stopped -p 1880:1880 -v node_red_data:/data nodered/node-red

npx node-red-admin hash-pw

docker exec -it nodered sh
vi /data/settings.js
#   adminAuth: {
#     type: "credentials",
#     users: [{ username: "admin", password: "<bcrypt-hash>", permissions: "*" }]
#   },
exit
docker restart nodered

# function node body
msg.payload = Number(msg.payload.t);
msg.topic = "temperature";
return msg;

# test message
mosquitto_pub -h broker.lab.example -p 8883 --cafile ca.crt -u sensor1 -P '<sensor1-password>' -t lab/sensor1/env -m '{"t":21.6,"h":48}'
Securing Node-REDNode-REDport 1880adminAutheditor loginHTTPSor reverse proxyLAN onlyno port forwardTrusted nodesreview paletteBackupsflows and credsUpdatesregular
Figure 2. Node-RED can run code, so its editor must be protected like an admin console.

How to verify and troubleshoot

The mqtt in node should show a green connected label. Add a debug node to see each message in the sidebar. The gauge should move when you publish a test value, and the chart should build a line over a few minutes. Open the editor in a private browser window: it must ask for a login.

  • Node shows disconnected: wrong port, CA file or credentials, or the name does not match the broker certificate.
  • Gauge shows nothing: the payload is still an object; check with a debug node and convert to a number.
  • Editor still open without login: the adminAuth block is commented out or in the wrong file; check the container logs.
  • Lost flows after update: you forgot the volume; always mount /data.

Security notes and clean-up

The Node-RED editor can run JavaScript and shell commands, so an exposed editor is a full compromise of the host. Keep it on the LAN or behind a VPN, use HTTPS through a reverse proxy if anyone else uses it, install only well-maintained nodes and export your flows (menu, Export) to Git, leaving credentials out. To remove the lab: docker rm -f nodered and, if you are sure, docker volume rm node_red_data.

Tip: a screenshot of a working dashboard plus a diagram of the data path makes a strong portfolio entry; see the IoT monitoring project.

Practice

Why is an unprotected Node-RED editor so dangerous?
Flows can run code and shell commands, so anyone who reaches the editor can control the host.
Why mount a volume at /data?
It stores flows, settings and credentials outside the container so they survive restarts and updates.
Your gauge does not move but the debug node shows {"t":21.6,"h":48}. What is wrong?
The gauge needs a single number; extract msg.payload.t into msg.payload first.

Key takeaways

  • Node-RED wires inputs, logic and outputs as visual flows.
  • Connect to the broker over TLS with a read-only user.
  • Always enable adminAuth before anything else.
  • Persist /data and back up flows without secrets.
  • Never expose the editor to the internet.
Tracks your learning on this device only. See your progress on the learning paths.

About the author

Mohamed Fayas

Founder of FM TecHub. CCNA certified, with a BTEC HND in Network Engineering, and BEng (Hons) in Computer Networking and Cloud Security. He writes practical, plain-English guides on networking, security and cloud.

More about the author

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Stay up to date by email

New notes, tools and security news from FM TecHub, explained simply. Free.

We only use your email to send these updates. See our privacy policy.