Why Raspberry Pi suits home automation
Unlike microcontrollers such as Arduino, Raspberry Pi runs a full Linux operating system. This means it can host web servers, run Python scripts continuously as system services, store data in local databases, and serve a browser-accessible dashboard — all on a single board drawing under 5 watts at idle.
For Polish hobbyists, Raspberry Pi 3 Model B and 4 Model B are the most common choices. Raspberry Pi 4 includes gigabit Ethernet and USB 3.0, making it better suited to projects that process video streams or run heavier services. Pi 3 remains adequate for sensor logging and relay control.
Project 1: Temperature and humidity logging
A DHT22 sensor connected to a GPIO pin provides temperature and humidity readings. The sensor's data pin connects to GPIO 4 (pin 7 on the 40-pin header) through a 10 kΩ pull-up resistor to 3.3V.
Software setup
Install Raspberry Pi OS Lite for headless operation. Enable the GPIO interface through raspi-config under Interface Options. Install the Adafruit DHT library via pip:
A minimal logging script reads from the sensor every 60 seconds and appends values to a CSV file:
Register this script as a systemd service to run at boot without requiring a logged-in user.
Project 2: Relay-controlled output
A 5V relay module (two-channel is typical) allows a Raspberry Pi to switch mains-voltage devices such as lamps or fans. The relay IN1/IN2 pins connect to GPIO pins 17 and 27. The relay module requires 5V for the coil; use the 5V pin on the header (pin 2 or 4).
Mains voltage wiring must comply with Polish electrical regulations. Any connection to 230V household circuits should be performed by a qualified electrician. The relay module itself operates at low voltage on the Raspberry Pi side.
Controlling relay state from Python
Project 3: Local web dashboard
Flask provides a lightweight HTTP server that runs on the Raspberry Pi and is accessible from any device on the local network. Install Flask via pip, then create a route that reads the CSV log and returns the most recent readings as JSON or renders an HTML template.
For data visualisation, Grafana can run on Raspberry Pi 4 and connect to a local SQLite or InfluxDB database. Grafana's web UI is accessible at port 3000 from any browser on the same network, requiring no cloud account.
Network and security considerations
For a dashboard that should not be reachable from outside the home network, no additional firewall configuration is needed — the home router's NAT prevents inbound connections by default. If remote access is required, a WireGuard VPN tunnel is more secure than exposing the Flask port directly.
Raspberry Pi OS includes ufw for local firewall rules. At minimum, restrict SSH access to the local subnet and disable the default password login in favour of SSH key authentication.
Polish component suppliers
Raspberry Pi boards and accessories are stocked by Botland and Nettigo, which also carry DHT22 sensors, relay modules, and jumper wire sets. PiHut ships to Poland from the UK as well, though delivery times are longer post-Brexit.