Which Model to Use
The Raspberry Pi 4 Model B remains the most capable single-board computer in the range for automation use. It ships with 1, 2, 4, or 8 GB of LPDDR4 SDRAM and runs from a USB-C power supply rated at 5.1 V / 3 A (15.3 W minimum). At Polish distributors, the 2 GB version sells for approximately 280–320 PLN, the 4 GB for 370–420 PLN.
For projects where the board will be embedded inside a panel, box, or enclosure with limited airflow, the Raspberry Pi Zero 2 W is worth considering. It draws substantially less power (peak ~2.5 W), supports Wi-Fi and Bluetooth, and shares the same 40-pin GPIO header layout as the full-size boards — making most GPIO-focused Python code directly portable between models.
GPIO: What the 40 Pins Can and Cannot Do
All 40-pin Raspberry Pi boards expose 26 general-purpose GPIO lines in the BCM numbering scheme. The key electrical constraints are:
- Logic level: 3.3 V (not 5 V tolerant — connecting a 5 V source to a GPIO pin without level-shifting will damage the SoC)
- Output current: 16 mA per pin maximum, 50 mA total across all GPIO simultaneously
- No built-in ADC: unlike Arduino, the Raspberry Pi cannot read analog voltages directly; an external ADC (MCP3008 via SPI, ADS1115 via I²C) is required
- I²C, SPI, UART, and PWM are available on specific pins; hardware PWM is limited to two channels (GPIO12/18 and GPIO13/19)
The 3.3 V-only rule is the most common source of hardware damage in beginner projects. Sensors designed for Arduino (5 V systems) often require a level shifter or a different operating voltage variant before connecting to Raspberry Pi GPIO.
Raspberry Pi Zero 2 W — same 40-pin GPIO layout as the full-size Pi, in a form factor suited to embedded enclosures. Image: Wikimedia Commons, CC BY-SA.
Temperature and Humidity Monitoring
The DHT22 (also sold as AM2302) is the most common sensor for combined temperature and humidity measurement in hobby automation. It communicates over a single-wire protocol and returns a reading every 2 seconds. The measurement range is −40 to +80 °C (±0.5 °C accuracy) and 0–100% RH (±2–5% accuracy depending on batch). For I²C-based alternatives with better long-term stability, the SHT31 or BME280 are preferred at the same price tier (15–35 PLN at Polish distributors).
Wiring the DHT22 to a Raspberry Pi: VCC to the 3.3 V pin, GND to any ground pin, DATA to a GPIO pin of your choice with a 4.7 kΩ–10 kΩ pull-up resistor to 3.3 V. The adafruit-circuitpython-dht library handles the single-wire timing in Python. Note that the DHT22 library uses bit-banging, which is sensitive to system load — on a busy Pi, missed readings are normal and the code should include retry logic.
Relay Boards for Mains-Voltage Control
Relay modules designed for 5 V Arduino control require adaptation for Raspberry Pi. Because the Pi's GPIO output is 3.3 V, some relay boards with an active-low trigger may not reliably switch when fed 3.3 V logic. Before purchasing, verify either:
- The relay module includes a built-in level-shifter or optocoupler that works at 3.3 V input, or
- The module has a jumper to select 3.3 V logic mode
For mains-voltage (230 V AC) applications, the relay board must be rated for the load current and voltage. A relay rated at 10 A / 250 V AC is appropriate for most household lighting and small appliance control. Never route mains cables across the same breadboard or PCB as the low-voltage logic circuitry; physical separation and appropriate insulation are mandatory.
Running Automations Locally with Home Assistant
Home Assistant is an open-source home automation platform that runs directly on Raspberry Pi via the dedicated Home Assistant OS image. It stores all data locally, requires no cloud account for core functions, and supports direct GPIO control through the Raspberry Pi GPIO integration. The installation process involves flashing the image to a microSD card (minimum 32 GB Class 10 or A2-rated) using the Raspberry Pi Imager tool.
Once running, GPIO pins can be defined as binary sensors (input) or switches (output) directly in the configuration files. A 1-second polling interval is typical for most switch-state monitoring. For time-critical logic (sub-100 ms response), dedicated Python scripts using the RPi.GPIO library and hardware interrupts provide more deterministic behaviour than the Home Assistant polling model.
Automation Software Comparison
Beyond Home Assistant, two other local-only options are used in Polish hobbyist communities:
- Node-RED: A flow-based visual editor that runs as a Node.js application. GPIO integration is available via the
node-red-node-pi-gpiopackage. Easier to configure for simple if-then logic without writing code. - OpenHAB: A Java-based platform with stronger support for legacy industrial protocols (KNX, Modbus). Heavier resource footprint than Home Assistant — requires at least 2 GB RAM for comfortable operation on Pi 4.