Self-Hosting n8n on Raspberry Pi: Workflow Automation for ESP32 Sensors, Home Assistant, and Notifications
Node-RED has been the default answer for visual automation on a Raspberry Pi for years, and it's still a great fit for tight sensor-to-actuator logic running on the same box as your ESP32 fleet. n8n solves a different problem: it's a workflow automation platform built around connecting APIs and services — HTTP webhooks, email, Slack, databases, cron schedules — with a node-based visual editor that's closer to Zapier or Make than to a hardware wiring diagram. Self-hosted on a Raspberry Pi, it's a genuinely useful way to glue your maker projects into the rest of your digital life: an ESP32 sensor posts a webhook when a threshold trips, n8n receives it, checks a condition, and sends a notification, logs to a spreadsheet, or triggers a Home Assistant scene — all without writing a server yourself.
n8n vs Node-RED: Picking the Right Tool
Node-REDn8n Best forLow-latency hardware/sensor logic, MQTT, GPIO-adjacent flowsAPI integrations, scheduled jobs, notification pipelines, multi-step business-style logic Data modelMessage objects flowing between nodes, very close to rawStructured JSON items with built-in expression editor between nodes Built-in service integrationsFewer, more DIY via HTTP request nodes400+ pre-built integrations (Gmail, Slack, Notion, Airtable, Google Sheets, etc.) Typical use on a maker PiTalking to MQTT brokers, ESP32 sensor networks, Home Assistant directlyTurning sensor events into notifications, logging, scheduled reports, and multi-service workflowsThey aren't mutually exclusive — a common pattern is Node-RED (or ESPHome/Home Assistant automations) handling the real-time hardware side and forwarding events to n8n over a webhook or MQTT trigger for anything that needs to reach outside services.
Installing n8n on a Raspberry Pi
n8n runs comfortably on a Raspberry Pi 4 or 5 with 4GB+ of RAM; it's a Node.js application, and the officially supported install path is Docker, which also makes backup and updates far simpler than a bare Node install. A Pi Zero 2W or Pi 3 will technically run it but expect a sluggish editor UI — budget a Pi 4 (4GB) or better if you're going to use it regularly.
sudo apt update && sudo apt install -y docker.io docker-compose-plugin sudo usermod -aG docker $USER # log out and back in for the group change to apply mkdir -p ~/n8n-data docker run -d --name n8n --restart unless-stopped \ -p 5678:5678 \ -v ~/n8n-data:/home/node/.n8n \ -e GENERIC_TIMEZONE="America/New_York" \ -e N8N_SECURE_COOKIE=false \ docker.n8n.io/n8nio/n8nAdjust the timezone to your own, and once the container is running, visit http://<pi-ip>:5678 to complete the first-run setup, which creates your local admin account. The N8N_SECURE_COOKIE=false flag is needed if you're accessing n8n over plain HTTP on your LAN rather than through HTTPS — if you put it behind a reverse proxy with a real TLS certificate (see below), you can drop that flag and run with secure cookies as intended.
Putting n8n Behind a Reverse Proxy
Running n8n on a raw port is fine for local testing, but if you want to reach it from outside your LAN (to receive webhooks from services that need a public endpoint, for instance), put it behind Nginx or Caddy with a proper domain and TLS certificate rather than port-forwarding 5678 directly. Caddy in particular makes this close to a one-liner:
# Caddyfile n8n.yourdomain.com { reverse_proxy localhost:5678 }Combine this with a service like Tailscale if you'd rather avoid exposing anything to the public internet at all — n8n's webhook triggers still work over a Tailscale-only address for workflows that only need to talk to other devices on your own network, and it sidesteps the public-exposure question entirely for hobby use.
Example: ESP32 Sensor Alert Pipeline
A practical starting workflow for a maker shop: have an ESP32 environmental sensor node (see this site's ESP32 sensor and MQTT guides) publish readings to an MQTT broker running on the same Pi, and set up an n8n workflow with an MQTT Trigger node subscribed to that topic. Add an IF node checking whether temperature or humidity crosses a threshold, and branch to a Telegram or email notification node on the "true" path, with a Google Sheets "Append Row" node logging every reading regardless of threshold for a running history you can chart later. This kind of workflow takes maybe twenty minutes to build in the visual editor and replaces what would otherwise be a small Python script, a cron job, and manual API wiring for each service you want to notify.
Credentials and Secrets
n8n stores service credentials (API keys, OAuth tokens) encrypted in its own database, separate from your workflow definitions — back up the encryption key (set via the N8N_ENCRYPTION_KEY environment variable, or auto-generated on first run and stored in the config directory) along with your workflow data, since losing it makes stored credentials unrecoverable even if you still have the underlying SQLite database file. Include the entire ~/n8n-data directory in whatever backup routine you're already running for the rest of your Pi's self-hosted services.
Resource Use and Performance Notes
n8n's footprint is modest at rest — under 200MB of RAM for the base install — but workflow execution, especially anything processing larger JSON payloads or running frequent scheduled triggers, will use CPU in bursts. On a Pi 4, dozens of lightweight workflows running on minute-level schedules are comfortable; if you're running something CPU-heavy (image processing, large data transforms) inside a workflow, consider whether that step belongs on a more capable machine and have n8n call out to it instead of doing the heavy lifting itself.
Keeping It Updated
Because n8n runs in Docker, updates are a pull-and-recreate: docker pull docker.n8n.io/n8nio/n8n followed by stopping and recreating the container with the same volume mount. Check n8n's release notes before major version bumps — workflow node behavior occasionally changes between major versions, and testing critical automations after an update is worth the five minutes it takes.
For a maker shop that already has an ESP32 sensor network and a Raspberry Pi humming along with Home Assistant or Node-RED, n8n fills the specific gap of connecting that hardware layer to the wider world of notifications, spreadsheets, and cloud services without writing custom integration code for each one. It's not a replacement for Node-RED's hardware-facing strengths, but paired together on the same Pi (or a dedicated one, if you're already running a cluster) they cover both ends of the automation problem well.