Skip to content

Guide

Node-RED Complete Guide: From First Flow to Home Automation

Node-RED from zero: install options, your first flow, the core nodes, ESP32 over MQTT, Dashboard 2.0, automations, reliable flows, security and a complete learning path.

  • 6 min read
  • Updated November 3, 2026
Node-RED Complete Guide: From First Flow to Home Automation

Quick answer: Node-RED is a free, browser-based visual programming tool for wiring devices, APIs and services together. You drag nodes onto a canvas, connect them into flows, and messages (msg, with the data in msg.payload) travel along the wires. Install it on a Raspberry Pi, PC or Docker, open http://<host>:1880, build Inject → Function → Debug as your first flow, then connect ESP32 boards through MQTT, add a Dashboard 2.0 interface, and automate with schedules and conditions. This guide is the roadmap, with links to a detailed tutorial for every step.

Node-RED runs on a computer, server or Raspberry Pi, not on the ESP32 itself. The ESP32 runs its own firmware, reads sensors and switches pins; Node-RED receives its messages and coordinates everything else.

Where to run itInstall commandGuide
Raspberry Pi (OS Bookworm)bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/update-nodejs-and-nodered-deb)Install on Raspberry Pi 5
WindowsInstall Node.js LTS, then npm install -g --unsafe-perm node-redInstall on Windows
Dockerdocker run -it -p 1880:1880 -v node_red_data:/data --name nodered nodered/node-redOfficial Docker docs
Home AssistantInstall the Node-RED add-on from the add-on storeHome Assistant docs
ESP32 sensors publish MQTT messages to a broker; Node-RED processes them and forwards data to a dashboard, a database and notifications

What Node-RED does, and where it runs

TermMeaning
NodeOne block that does one job: inject a message, subscribe to MQTT, run JavaScript, send an email
FlowA tab of connected nodes
Message (msg)The JavaScript object passed along a wire; data lives in msg.payload, a label often in msg.topic
DeploySaves and starts your changes (the red button, top right)
PaletteThe node library on the left; add more via Menu → Manage palette
ContextMemory between messages (flow.set, global.get)

A temperature workflow might receive a reading from an ESP32, convert it to a number, compare it with a threshold, update a gauge and send an alert only when needed. Each stage is visible and testable on its own. That transparency is Node-RED's superpower, but a simple-looking flow can still be unreliable if it ignores reconnects, bad data or errors, so learn the message model first.

Step 1: understand nodes, flows and messages

Build the classic first flow: Inject → Function → Debug.

  1. Drag an inject node onto the canvas; set its payload to a number, for example 21.5.
  2. Add a function node with:
script.js
msg.payload = msg.payload * 9 / 5 + 32;   // °C to °F
msg.topic = "temperature_f";
return msg;
  1. Add a debug node, wire the three together, click Deploy, then click the inject node's button. The Debug sidebar shows 70.7.

Change one thing at a time and keep a debug node after anything you're unsure about. Detailed walk-throughs: Your first flow: inject, function and debug and Nodes, flows and msg.payload explained.

The core nodes you'll use constantly

NodeUse
injectStart a flow by hand or on a schedule
debugSee what a message contains
functionCustom JavaScript
changeSet, move or delete message properties without code
switchRoute messages by value (if/else)
delay / triggerRate-limit, wait, or build timeouts and watchdogs
mqtt in / mqtt outTalk to ESP32s and other devices through a broker
http in / http response / http requestBuild APIs or call web services
catch / statusHandle errors and watch connections

Step 2: run Node-RED reliably

A Raspberry Pi makes a good always-on automation host. Install Node-RED on Raspberry Pi 5 covers the official script, running it as a service with sudo systemctl enable nodered, and opening the editor from another computer. On Windows, see install Node-RED on Windows.

Check three things before relying on it: the service starts after a reboot, you can open the editor at the host's LAN address, and your flows still behave correctly after a restart.

Step 3: connect devices with MQTT

MQTT is a publish/subscribe messaging protocol often used to connect constrained devices and automation systems. A device publishes a message to a topic; a broker routes it to subscribers. Node-RED can publish with MQTT Out nodes and receive messages through MQTT In nodes.

Follow Node-RED with MQTT: Connect Mosquitto, Publish & Subscribe to connect the editor to an existing broker and test messages before adding hardware. Then use Install Mosquitto on Raspberry Pi 5 if you want to host your own broker.

Use clear topic names, distinguish commands from reported state, and decide whether a message should be retained. A retained command such as ON can be replayed to a reconnecting device; that may be wrong for a physical actuator. Retained state is often safer than a retained one-shot action.

MQTT In → validation → dashboard, database or notification, with a separate MQTT Out path for commands; state and command topics kept apart

Step 4: take the flow to real ESP32 hardware

Once the broker path works, connect a real board. Control an ESP32 LED with Node-RED and MQTT sends explicit ON and OFF commands through MQTT and reports device state back. It is a useful first hardware integration because it makes the whole command path visible without requiring a sensor.

A reliable design separates command and reported-state topics. Do not assume publishing an ON command proves the pin changed. Wait for state feedback or a meaningful acknowledgement, and show connection status separately from the output's last reported state.

For sensors, validate incoming payloads before converting them to numbers. Reject empty strings, unexpected JSON shapes and out-of-range values rather than silently turning them into zero. For relay and mains projects, hardware safety and appropriate isolation matter regardless of whether the command came from a dashboard or an automation.

Step 5: build a modern dashboard

For new dashboard work, use FlowFuse Dashboard, often called Dashboard 2.0, package @flowfuse/node-red-dashboard. The legacy node-red-dashboard package is deprecated. Install the modern package from Palette Manager and build the interface with its own UI nodes; do not assume legacy nodes and settings will transfer unchanged.

Start with Node-RED Dashboard 2.0: Install Buttons, Switches & Gauges. Build a button, a switch and a gauge, and connect each widget to a flow that validates inputs and reports its result. For real hardware, update displayed state from device feedback rather than trusting the browser widget's last click.

Read the official Dashboard 2.0 getting-started guide and migration guide before upgrading an existing interface.

Step 6: add sensors, serial data and HTTP APIs

Data can reach Node-RED in several ways:

  • MQTT: a good fit for Wi-Fi devices such as ESP32 boards that publish structured measurements.
  • Serial: useful when an Arduino Uno or Nano sends newline-delimited readings over USB. Select the correct port and baud rate; keep debugging text separate from machine-readable data.
  • HTTP: useful when a device sends JSON to an endpoint or a flow calls an external API. Validate method, body shape, authentication and response codes.
  • Camera snapshots: an ESP32-CAM can expose or send an image, but browser access, network routing and authentication should be designed explicitly.

For a live sensor dashboard, label units and timestamps. A stale sensor value is not the same as a zero reading, and no incoming message should not be mistaken for a valid measurement.

Step 7: move from a demo to useful automation

A dashboard lets a person request an action. An automation decides when to act. Begin with a schedule or an LDR-based lighting rule, then add conditions such as occupancy, time window and a minimum interval between actions.

For motion alerts, use a state transition to detect the start of an event, then add a delay, rate limit or cooldown. Otherwise a PIR sensor held HIGH may create dozens of messages. Make notifications idempotent where possible: repeated input messages should not create repeated physical actions or a flood of alerts.

If you store measurements, give each record a timestamp and clear unit. InfluxDB is designed for time-series measurements; Grafana can query and visualize them. Decide a retention period early, and do not store unlimited debug messages as a substitute for a data model.

Step 8: make flows understandable and recoverable

As a flow grows, use subflows for reusable logic, Link In/Out nodes to separate areas of a workspace, and Catch nodes to route supported node errors to an explicit handler. Label nodes according to their purpose, validate messages at system boundaries, and handle empty or malformed data intentionally.

Keep operational state separate from the last measurement. A sensor may report 0 °C; that does not mean it has disconnected. Track last-seen time, device availability and timestamp alongside values. Decide what should survive a restart and configure context storage accordingly; in-memory context alone is not durable.

Export important flows regularly, store reviewed exports in Git, and document credentials as environment/configuration requirements rather than embedding secrets in shared flow JSON. A backup should be restorable; periodically prove you can restore it to a test instance.

A robust automation: input validation, a Catch error branch, cooldown and retry logic, status tracking and a notification output

Security before remote access

A default Node-RED editor is not a public-facing authenticated control panel. The official documentation warns that the editor is unsecured by default; anyone who can reach it may be able to modify flows. On a trusted LAN this may be acceptable for initial development, but it is not appropriate for direct internet exposure.

Before remote access, configure editor/admin authentication, HTTPS or a secure reverse-proxy setup, restrict network access, and secure HTTP endpoints and dashboards. Use MQTT authentication, topic access controls and TLS when traffic crosses networks you do not trust. Store tokens and passwords outside exported flows, redact secrets from screenshots, and keep Node.js, Node-RED and installed nodes updated.

Step-by-step: Secure Node-RED: login, HTTPS, MQTT TLS and backups. Official reference: Securing Node-RED. Never port-forward editor port 1880 straight to the internet; use a VPN instead.

Beginner troubleshooting

SymptomLikely causeFix
Can't open http://<host>:1880Node-RED not running, wrong IP, or firewallnode-red-start (Pi) or check the service; use the host's LAN IP; allow port 1880
Changes do nothingNot deployedClick Deploy after every edit
Debug shows nothingDebug node not wired, or disabled (green tab on the right)Wire it and enable it
Function errors like "msg is not defined" or nothing passesMissing return msg;End function code with return msg;
MQTT node stuck on "connecting"Wrong broker IP, user/password, or broker refusing remote clientsSee Node-RED with Mosquitto
Payload is a string, comparisons failMQTT/HTTP delivered textSet mqtt in to parsed JSON, or Number(msg.payload)
Dashboard page 404 at /uiOld dashboard URLDashboard 2.0 is at /dashboard
Flows lost after a restartRunning a temporary install, or editing a different user directoryCheck the log for the flows file path; back up ~/.node-red

Frequently asked questions

Is Node-RED free? Yes, it's open source (Apache 2.0). FlowFuse offers paid hosting if you'd rather not run it yourself.

Do I need to know JavaScript? Not to start. Many flows use only change, switch and template nodes; Function nodes accept JavaScript when you need it.

Does Node-RED run on an ESP32? Normally no. Run the Node-RED runtime on a computer, Raspberry Pi or server and let the ESP32 execute its own firmware while exchanging data through MQTT, HTTP or another transport.

Should I use the old Dashboard package? For new work, start with @flowfuse/node-red-dashboard. The legacy package is deprecated; plan migration rather than mixing tutorials written for different node sets.

Can Node-RED control GPIO on Raspberry Pi 5? Raspberry Pi 5 uses the RP1 I/O controller and its GPIO software stack differs from older models. Do not copy a legacy GPIO-node tutorial without checking current Pi 5 support and testing the exact hardware/software combination. For a portable first hardware path, use an ESP32 over MQTT and keep the Pi as the server.

Can I expose the editor over the internet? Not without a deliberate security design. Add authentication, encrypted access and network restrictions; a public port-forward is not sufficient.

Continue learning

Related articles

All articles

Signal In

Built from what makers search for

The lookups piling up in SolderHub's search bar every day shape what we publish next — new component pages, board guides, and firmware notes, sent out as they go live.

By subscribing you agree to our Privacy Policy. Unsubscribe anytime.