The idea behind this project is the one that matters most to me when I talk about smart homes: your data stays at home. No subscriptions, no third-party servers, no sensor shipping your living room's temperature off to who-knows-where. Just hardware you own and open-source software. Here's how I built it.
Hardware and Setup
The shopping list is deliberately minimal. You don't need much to get started:
- Raspberry Pi 5 (4 GB): the brain of the system. n8n, the database and Grafana all run on it together, without breaking a sweat. A Pi 4 works just fine too.
- DHT22 sensor: measures temperature and humidity with good accuracy (±0.5 °C). Costs a few euros and is the classic starting point for home IoT.
- Jumper wires and a 10kΩ resistor: to connect the DHT22 to the GPIO pins. The sensor has three wires — power, data and ground — and the pull-up resistor on the data line keeps readings stable.
- Official power supply: with the Pi 5 it's worth not cutting corners on power, to avoid reboots under load.
A detail I appreciate: power consumption. The whole setup draws 4-6 watts on average, even with all services running. Keeping it on 24/7 works out to about €1.50 a month on the electricity bill — less than a coffee, for an always-on system.
Reading the Data with Python and n8n
The DHT22 is easy to query from Python with the adafruit-circuitpython-dht library. My script does three things: reads the sensor, builds a small JSON with temperature, humidity and timestamp, and sends it to n8n.
The bridge between the sensor and the automation is an n8n webhook. The Python script does a simple POST to the webhook URL every 60 seconds (handled by a system cron). The flow is this:
- The Python script reads the DHT22 and sends
{ "temp": 24.3, "hum": 48, "ts": "..." }to the webhook. - n8n's Webhook node receives the data and passes it into the flow.
- A write node saves the reading to a time-series database (I use InfluxDB, but a SQLite table works fine too for getting started).
- The same flow checks whether the temperature has crossed a threshold — which is where alerts come in, more on that below.
The advantage of going through n8n instead of writing everything in Python is that every logic change — a new threshold, a new destination, a new alert — I make by dragging nodes, without touching code and without restarting anything.
Real-time Dashboard with Grafana on the Pi
Raw data doesn't say much: you need charts. Grafana is the perfect tool and runs comfortably on the same Raspberry Pi.
Installation is straightforward: add Grafana's official repository, install the package and enable the service. Within a few minutes you have the web interface reachable on the local network at port 3000.
The configuration that matters is the datasource:
- Add InfluxDB (or whichever database you chose) as the data source, pointing to
localhostsince it runs on the same machine. - Create a panel with the temperature query and set auto-refresh to 30 seconds.
- Add a second panel for humidity and, if you like, a visual threshold that turns the chart red when the limit is exceeded.
Watching the temperature curve update in real time on your phone, while you're comfortably on the couch, gives a small but real maker satisfaction.
Automatic Telegram Alerts
A dashboard is only useful if you're looking at it. To be notified even when I'm not thinking about it, I added Telegram alerts directly inside n8n.
The logic is simple and lives in the same flow that receives data from the sensor:
- An IF node checks on every reading whether the temperature has crossed the threshold (for me, 28 °C in summer, under 16 °C in winter).
- If the threshold is exceeded, a Telegram node sends me a message like "Office at 29.1 °C — turn on the AC?".
- An anti-spam check: I save the time of the last alert and only send a new one if at least an hour has passed, so I don't get twenty notifications for the same heat wave.
With a few more nodes, the same mechanism could even trigger a smart plug to turn on a fan — but that's material for a future article.
Conclusion
With under a hundred euros of hardware and a few hours of tinkering, I have an environmental monitoring system that's entirely mine: no subscriptions, no data leaving the house, total freedom to modify it. It's the perfect small project for understanding how sensors, automation and visualization talk to each other.
DIY IoT isn't just a hobby: it's the best way to take back control of the technology around us. If these topics interest you, subscribe to the newsletter — the next article is dedicated to automating a smart plug.