Misc RPi Projects
The Adventures of my 3 RPis
Raspberry Pi’s are little single PCB computers that can run linux, A while back I bought three RPi4’s to learn how to set up and run a kubernetes cluster, but since then they have lived many lives - I thought it might be an interesting post to explore the different usecases and fun little projects that these computers have enabled.
I will likely intermitently update this post as I progress on different projects.
K8s Cluster
The maiden project for thesee RPi’s was to form a mini kubernetes cluster. I had thought this would be a tricky task, but it turns out setting up a cluster (without any security considerations) is arguably not that hard.
I imaged each Pi with Ubuntu Server 20.04, installed MicroK8s on each, chose one as the control plane, and added the others to it.
I then tried to deploy Rancher on it and ran into ARM related issues and decided to just move my learning onto a cloud based k8s environment.
I ended up learning a lot about kubernetes, and was able to leverage that knowledge significantly at work, somewhat thanks to these little computers!
Timelapses
A friend who I was flatting with then I was tinkering with the Pi cluster had a Camera Module (we called it PiCam) that I ended up borrowing.
I put together a little script that takes a picture every N seconds, and saves the images in a images/
dir. I set this up on the Pi and would leave it for a while, pointing and something interesting. After some time had passed I would sftp
the files onto my main computer and use ffmpeg
to stitch the frames into a video.
I’m taking some cool time lapses of my partners fish tank and her plants. I haven’t got a nice timelapse to show currently but I will upload some when I wrangle all the images from the respective Pis and run the magic ffmpeg
command (Two of them are collecting time lapses at the time of writting).
I ended up buying a nicer PiCam when I moved flats, its so cute, like a little DSLR, and I got an IR camera to record the plants at night time. To attach the camera modules to the RPi’s me and my flatmate designed a mount for the cameras to the RPi using FreeCAD:
CAD files here
I also got a little carried away with trying to automate the collecting of the images and creation of the time lapse, setting up cron jobs on my main server.
My crontab on the server ended up looking like this:
# m h dom mon dow command
0 * * * * rsync -vrah rpi3:/home/jerome/timelapse/images/ /media/3tb/timelapse/std_cam/ && ssh rpi3 "find ~/timelapse/images/ -type f -mmin +60 -delete"
0 * * * * rsync -vrah rpi2:/home/jerome/timelapse/images/ /media/3tb/timelapse/ir_cam/ && ssh rpi2 "find ~/timelapse/images/ -type f -mmin +60 -delete"
30 12 * * * make_timelapse -v -d /media/3tb/timelapse/ir_cam/ /media/3tb/timelapse/ir_cam.mp4
30 03 * * * make_timelapse -v -d /media/3tb/timelapse/std_cam/ /media/3tb/timelapse/std_cam.mp4
This will pull all the images from my second and third RPi’s onto the 3tb harddrive I have on my flat server every hour. And it will run the make timelapse script (found in the repo) once each day at different times (it’s pretty resource intensive). I spent a good amount of time making the make_timelapse
script into a super user friendly bash cli utility.
Pi Hole
I set up a Pi Hole on one of the RPi’s to block ad for our whole network. It was super effective! However, some of my flatmates got annoyed because they couldn’t click on the Ads that they normally did.
Hosting silly servcies for my flat
I’ve constantly been making little HTTP API and other services to do silly things around the flat, including:
- Make random noises (web server, rabbitMQ, and a consumer in golang)
- Turn my bedroom lights on and off (Typescript HTTP here)
- Control the yeelight LED strip around my PC (collaboration effort here)
- Record on a microphone and transmit the spectral data to the browser via websockets and display a waterfall spectrogram (code here).
Network scanning
I also recently learn about nmap (and a bunch more about networking more generally) and have been super interested in scanning every network that I connect to. I also realised that I could figure out who was home in the flat by scanning the network for their phones. So we had a little dashboard showing who was home, based on the outputs of nmap running on a cron job on a raspberry Pi.
Fish tank instrumentation
My latest application for a RPi is to monitor the conditions in my partners fish tank. She has recently started a Reef fish tank and making sure the pH, salinity, temperature, nitrogen levels, etc, are perfect is super important for the fish to survive. I have been enjoying using grafana and prometheus for a few other projects and I want her to have a neat dashboard to monitor her fish tank.
Currently a WIP, I have a pH sensor, a temperature sensor, and an ADC. I have voltages being measured but I still need to understand and calibrate all the sensors. More from this soon!
SteamLink
I’ve recently set up a rpi in the lounge of my flat to stream games from my PC (with a decent gpu) to the TV.
It works really well for party games like Speedrunners and Duck Game.
We noticed a lot of latency / lag spikes over WiFi, but it works really well when connected via ethernet.
In order to make sure steamlink booted up when the pi was turned on I added a systemd unit:
[Unit]
Description=Start Steam Link at desktop load
[Service]
Type=simple
User=jerome
ExecStart=/usr/bin/steamlink
#Restart=always
Restart=on-failure
[Install]
WantedBy=graphical.target
#WantedBy=multi-user.target
At /etc/systemd/system/steamlink.service
and enabled it with:
sudo systemctl enable steamlink.service
sudo systemctl start steamlink.service