Node red

Uit MakerSpace Leiden
Naar navigatie springen Naar zoeken springen

Node-RED is a visual programming tool that lets you connect hardware devices, APIs (like web services), and online platforms using a simple drag-and-drop interface. It is built on Node.js and widely used for Internet of Things (IoT) projects, automation, and system integration. Think of it as a way to “wire” digital tasks together without needing a lot of traditional programming.

We use Node-RED at our makerspace to:

  • Read and write data on **MQTT** (a lightweight messaging protocol used in many IoT applications)
  • Connect sensors and microcontrollers to dashboards
  • Automate workflows across services (e.g., when a sensor reads a value, send a message or update a database)
  • Build simple web-based interfaces to control or monitor devices


Accessing Node-RED

Node-RED runs as a service on our internal server. To access it remotely, you can create an SSH tunnel from your computer to the server:

ssh -L 1880:localhost:1880 user@hostname

Once connected, open your browser and visit: [1](http://localhost:1880) You’ll see the Node-RED flow editor.

Running as a systemd Service

Node-RED is configured to start automatically as a background service (daemon) using `systemd`. Below is the service file used on our server. It ensures Node-RED starts on boot and restarts if it crashes.

# To consult the log : journalctl -u Node-RED
[Unit]
Description=Node-RED is a tool for wiring together hardware devices, APIs and online services in new and interesting ways.
After=syslog.target network.target
Documentation=http://nodered.org/

[Service]
Environment="NODE_OPTIONS="
Environment="NODE_RED_OPTIONS=-v"
#Full Path to Node.js
ExecStart=/usr/bin/node-red $NODE_RED_OPTIONS -- $NODE_OPTIONS
WorkingDirectory=/home/nodered/nodered
# User/Group that launches node-RED (it's advised to create a new user for Node-RED)
# You can do : sudo useradd node-red
# then change the User=root by User=node-red
User=nodered
Group=nodered
Nice=10
SyslogIdentifier=Node-RED
StandardOutput=syslog
# Make Node-RED restart if it fails
Restart=on-failure
# Node-RED need a SIGINT to be notified to stop
KillSignal=SIGINT

[Install]
WantedBy=multi-user.target

To enable and start the service:

sudo systemctl enable nodered
sudo systemctl start nodered

To check logs:

sudo journalctl -u nodered.service