Raspberry Pi Home Lab
Aug 9, 2024 (4 months ago)
6 min read •
After getting my own Linux server, I wanted to have a server that I could use for my home. I wanted to use a Raspberry Pi, because it is cheap, easy to setup and has a lot of software that I can use. I also wanted to use Docker, because I like to have my software in containers. In this blog post I will explain how I set my Raspberry Pi up and how I use it.
Table of contents
Specifications
- Raspberry Pi 5 with 8 GB RAM
- SanDisk Ultra microSDHC 128GB 140MB/s A1
- Raspberry Pi 27W USB-C-power adapter black EU
- Argon ONE V3 M.2 NVME PCIE case SDSQUA4-128G-GN6MN
Total: ** ~150€**
Setup
Preparation
- Get the Raspberry Pi Imager
- Select the latest Raspberry Pi OS image (full)
- Configure the image
- Hostname:
raspberrypi
- Username/Password: ...
- Wifi SSID/Password: ...
- Timezone: Europe/Berlin
- Keyboard layout: de
- SSH: Enabled (Optional: Add your public key)
- Flash the image to the SD card
Installation
The Argon ONE case had one issue where the start button didnt work. The power jumpers (the 1/2 vs the 2/3 connection, which controls the power behavior) had a problem where only the 2/3 connection worked.
-
Assemble the SD card and case with the Raspberry Pi
-
Boot up
-
Test with ssh and with a display
-
Update the system
sudo apt update -y
sudo apt upgrade -y
# If required, reboot
sudo reboot
Configuration
For the initial configuration, I setup a few basic stuff: git, neovim, docker and NodeJS.
sudo apt install git curl wget gcc neovim
git config --global credential.helper store
git clone https://github.com/alex289/astronvim_config.git ~/.config/nvim
# Install NodeJS
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
nvm install node
# Add Dockers official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
# VERSION_CODENAME should be sth like bookworm
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "bookworm") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Static IP
One important thing to do is to set a static IP for the Raspberry Pi. This is important because I want to use the AdGuard Home DNS server to resolve my domains and block ads.
One problem I encountered was that my router didnt have a DHCP server to set IPs. Luckily, there are multiple solutions:
- Use AdGuardHome as a DHCP server
- Set a static IP on the pi itself
Software
AdGuard Home
One of the most popular projects to use on a Raspberry Pi is AdGuard Home, which is a DNS server that can be used to block ads and resolve domains. I was also considering using Pi-hole, but the UI and the configuratino of AdGuard convinced me.
I didnt use Docker here on purpose, because I wanted AdGuard to be more near to the os and hardware to improve performance. I dont think this makes much of a difference, but since there is no disadvantage, I will use the basic installation here.
cd
# Get the arm version of the pi
cat /proc/cpuinfo
# Replace armv6 with the ARM version that is best supported by your Pi
wget 'https://static.adguard.com/adguardhome/release/AdGuardHome_linux_armv6.tar.gz'
tar -f AdGuardHome_linux_armv6.tar.gz -x -v
cd ./AdGuardHome/
sudo ./AdGuardHome -s install
# AdGuardHome -s status
Glances
Glances is a monitoring tool which provides a UI that shows all hardware and software information of the system. I just wanted something lightweight and simple to just show me the current status of my system. It really has all information I could need and has a responsible UI.
Home Assistant
One of my childhood dreams was to have a home automation system. Home Assistant is a great project that can be used to control all kinds of devices. As I already had a smart TV I could try to get used to it before getting all kinds of IoT devices. One cool thing about this is that it has an integration for AdGuard Home where I can control different things.
I know it is recommended to use the Home Assistant Operating System but since I want to use other stuff I chose Docker. Maybe in the future I will get another Raspberry Pi and split my homelab into two servers.
services:
homeassistant:
container_name: homeassistant
image: 'ghcr.io/home-assistant/home-assistant:stable'
volumes:
- ./home-assistant-data:/config
- /etc/localtime:/etc/localtime:ro
- /run/dbus:/run/dbus:ro
restart: unless-stopped
privileged: true
network_mode: host
Zigbee2mqtt
A lot of smart home devices only work with Zigbee which is a specification for a suite of high-level communication protocols. In order to use Zigbee devices you need a Zigbee Router like the SLZB-06. In combination with a Zigbee2mqtt adapter you can use the Zigbee devices with Home Assistant.
services:
mqtt:
container_name: mqtt
image: eclipse-mosquitto:2.0
restart: unless-stopped
volumes:
- './mosquitto-data:/mosquitto'
ports:
- '1883:1883'
- '9001:9001'
command: 'mosquitto -c /mosquitto-no-auth.conf'
zigbee2mqtt:
container_name: zigbee2mqtt
image: koenkk/zigbee2mqtt
restart: unless-stopped
volumes:
- ./zigbee2mqtt-data:/app/data
- /run/udev:/run/udev:ro
ports:
- 8080:8080
environment:
- TZ=Europe/Berlin
permit_join: true
mqtt:
base_topic: zigbee2mqtt
server: mqtt://mqtt
serial:
# Replace the ip address with your SLZB-06 ip
port: tcp://192.168.1.12:6638
frontend:
port: 8080
advanced:
network_key: GENERATE
Tailscale
In my last post I already wrote about how I use Tailscale to connect to my Server. Just for completeness, I installed it on my Raspberry Pi too.
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up
One advantage of this is that my ubuntu server can now access my Raspberry Pi via Tailscale. This means I can configure my reverse proxy to function as a tunnel for home assistant so I can access it outside of my local network.
MagicMirror
The coolest thing to have in your home in my opinion is a MagicMirror. When friends visit you and they see a mirror with some calendar, clock and weather, they will be very impressed. Also its great to have the most import information in one place where you would at anyway.
cd
git clone https://github.com/MagicMirrorOrg/MagicMirror
cd MagicMirror/
npm run install-mm
# If no existing config
cp config/config.js.sample config/config.js
# Setup ICloud calendar sync
# https://forum.magicmirror.builders/topic/5327/sync-private-icloud-calendar-with-magicmirror?page=1&lang=de
# If on the Raspberry Pi
npm start
# Via SSH
DISPLAY=:0 nohup npm start &
Modules
This is a list of all the modules I use.
- Alert: Shows some alerts when something happens
- Update notification: Shows a notification when a new update is available
- Clock: Shows the current time lol
- Calendar: Shows my iCloud calendar events
- Compliments: Who doesnt like compliments?
- Weather: Shows the current weather and the forecast
- News: Shows some RSS feeds of some news sources to show you the latest news
- DailyPokemon: Shows a pokemon with its stats and switches everyday.
- OnSpotify: Shows the current song played on Spotify with album cover, artist and song name. (With a touchscren you could even control it)
Conclusion
In conclusion, I had lot of fun setting up my Raspberry Pi and I am very happy with the result. Im excited what I will do with it in the future with it.
If you have any questions or suggestions, feel free to contact me. Thanks for reading!