Gateways, edge and back ends
How data gets from a sensor to a chart you can trust. Linux gateways, MQTT brokers, Home Assistant, Node-RED, time-series storage and dashboards, with the defaults that catch people out.
Overview
A sensor on its own produces numbers that nobody sees. Something has to receive them, keep them, show them and act on them. That something is the gateway and the back end. This hub is for makers setting up a first home server and for product teams deciding what runs on site, what runs in a data centre, and how the two talk.
The pattern that works for both readers is the same: devices publish to a message broker, one or more consumers subscribe, and storage and dashboards sit behind the consumers. Whether the broker runs on a Raspberry Pi in a cupboard or on a rented server is a deployment choice, not a different architecture. Keeping that separation is what keeps a design vendor-neutral.
Key ideas
The broker is the contract
MQTT is a publish-subscribe protocol: devices publish to named topics on a broker, and consumers subscribe to the topics they need. MQTT 5.0 has been an OASIS Standard since 7 March 2019. Eclipse Mosquitto, a common open-source broker under the EPL/EDL licences, implements MQTT 5.0, 3.1.1 and 3.1. Once the topic tree and payload format are fixed, you can replace any consumer without touching the devices. Design the topic tree first and treat it as an interface with a version. The messaging hub covers topics, quality of service (QoS) and payload formats in detail.
Home Assistant adds one constraint here. Its MQTT integration requires a broker that supports MQTT protocol version 5, and it recommends the Mosquitto broker app. Its discovery scheme listens under the homeassistant prefix by default, so a device that publishes a configuration message to homeassistant/<component>/<object_id>/config appears without manual set-up.
Know when a device has gone
A dashboard that shows the last value forever hides a dead sensor. MQTT handles this with the Will Message. A client registers it when it connects, and the broker publishes it if the client drops off without a clean DISCONNECT, for example on a network failure or a missed keep-alive (MQTT 5.0, section 3.1.2.5). Publish an “online” retained status at start-up and register “offline” as the Will, and every consumer can tell stale data from fresh.
The gateway must survive the uplink
Edge processing earns its place when the site has to keep working without the internet. A local broker, local automations and local storage keep running when the uplink drops. A Mosquitto bridge connects the local broker to a remote one and forwards chosen topics out, in or both (the default is out). Two Mosquitto defaults matter for this. persistence is false, so queued messages live only in memory until you turn it on, and autosave_interval then writes to disk every 1800 seconds. max_queued_messages caps the queue at 1000 QoS 1 and 2 messages per client. Size both against the longest outage you expect.
Storage: history, statistics and the right database
Home Assistant’s recorder stores history in SQLite by default (home-assistant_v2.db) and keeps 10 days unless you change purge_keep_days. Sensors with a state_class of measurement, total or total_increasing also get long-term statistics: hourly values that are not purged. Raw readings older than 10 days are gone unless you export them, and the InfluxDB integration does that by copying every state change to an external InfluxDB.
Outside Home Assistant, pick the database by the query you will run. InfluxDB 3 Core stores data as Parquet files on local disk or object storage and is MIT or Apache 2.0 licensed at your choice. TimescaleDB is a PostgreSQL extension, which suits teams that already run PostgreSQL. Its open-source edition is Apache 2.0, while the Community edition is under the Timescale License, so check which features you need before you build on it. Prometheus pulls metrics over HTTP and its documentation says it is not the right store when you need 100 % accuracy, so use it for gateway health, not for billing-grade meter readings.
Linux boards as gateways
A Raspberry Pi 5 (Broadcom BCM2712, four Arm Cortex-A76 cores at 2.4 GHz, 1 GB to 16 GB of LPDDR4X, Gigabit Ethernet, a PCIe 2.0 x1 interface and a 5 V, 5 A USB-C input) is one of the boards Home Assistant has an install guide for. Raspberry Pi states it will stay in production until at least January 2036, which matters for a product. Home Assistant Operating System, the recommended installation type, needs a Pi 4 or 5 with at least 2 GB of RAM. Its install guide asks for an SD card of at least 32 GB, ideally Application Class 2 (A2), and warns against powering the board from a computer USB port.
For makers
Install Home Assistant Operating System on a Raspberry Pi 4 or 5, add the Mosquitto broker app, and let MQTT discovery create your entities. Raise purge_keep_days if you want more than 10 days of raw history, or rely on the hourly long-term statistics. Add Node-RED only when you need logic that automations make awkward.
For product teams
Run the broker, the consumers and the database as separate services with their own upgrade cycles. Turn on broker persistence, size queues for your longest outage, and bridge to the central broker with TLS and per-site credentials (security hub). Record every component’s licence: AGPLv3 for Grafana, the Timescale License for parts of TimescaleDB. Pick board models with a stated production lifetime.
Where to start
Start with /learn/beginner/07-mqtt-basics/, which sets up a local Mosquitto broker, then /learn/beginner/09-a-local-dashboard/, which puts a dashboard on your own network without a cloud account. /learn/beginner/06-wifi-and-your-first-request/ covers the device side. The MQTT cheat sheet keeps topics, QoS and retained messages on one page. For site equipment that speaks Modbus or OPC UA, continue to the industrial IoT hub. For updating a fleet of gateways, see OTA and fleet management.
Tools and platforms
Versions and licences as of 28 November 2026.
| Job | Pick | Why, from its own documentation |
|---|---|---|
| Home server with a user interface | Home Assistant OS | Recommended installation type; Container lacks out-of-the-box Thread and Z-Wave |
| Message broker | Eclipse Mosquitto | MQTT 5.0, 3.1.1 and 3.1; EPL/EDL; bridges to other brokers |
| Visual glue logic | Node-RED 5.0.10 | Flow-based, browser editor, Apache 2.0; 5.x needs Node.js 22 or later |
| Node-RED dashboard | @flowfuse/node-red-dashboard |
Named replacement for node-red-dashboard, deprecated 27 June 2024; Apache 2.0 |
| Sensor time series | InfluxDB 3 Core | Parquet on disk or object storage; SQL and InfluxQL; MIT or Apache 2.0 |
| Time series next to relational data | TimescaleDB | PostgreSQL extension; Apache 2.0 and Timescale License editions |
| Gateway health metrics | Prometheus | Pull over HTTP; not for data that must be 100 % accurate |
| Charts and alerts | Grafana | Core data sources include InfluxDB, Prometheus, PostgreSQL, MySQL; AGPLv3 |
| MQTT into a database | Telegraf mqtt_consumer |
Subscribes to topics and can turn topic segments into tags |
| Gateway hardware | Raspberry Pi 5 | Gigabit Ethernet, PCIe 2.0 x1; in production until at least January 2036 |
Grafana has no core MQTT data source, so put a collector or a database between the broker and the charts.
Common mistakes
- Expecting Home Assistant to keep raw history for a year. It keeps 10 days by default, plus hourly statistics for sensors with a
state_class. - Running Mosquitto with persistence off and then losing queued messages on a restart.
- Building a new Node-RED project on
node-red-dashboard, which has been deprecated since 27 June 2024. - Pointing Home Assistant at a broker that only speaks MQTT 3.1.1.
- Showing the last value of a sensor without a Will Message, so a dead device looks healthy.
- Using Prometheus as the store for meter readings that must add up exactly.
- Coupling devices to one consumer’s payload format instead of a documented topic tree.
Going deeper
- MQTT Version 5.0, OASIS Standard, 7 March 2019. Section 3.1.2.5 covers the Will Message.
- mosquitto.conf, the reference for bridges, persistence and queue limits.
- Home Assistant recorder and MQTT integration documentation.
- Node-RED supported Node.js versions.
- InfluxDB 3 Core documentation and TimescaleDB.
- Prometheus overview, including when it does not fit.