The Changelog The Changelog #489

Run your home on a Raspberry Pi

This week we’re joined by Mike Riley and we’re talking about his book Portable Python Projects (Running your home on a Raspberry Pi). We breakdown the details of the latest Raspberry Pi hardware, various automation ideas from the book, why Mike prefers Python for scripting on a Raspberry Pi, and of course why the Raspberry Pi makes sense for home labs concerned about data security.

Use the code PYPROJECTS to get a 35% discount on the book. That code is valid for approximately 60 days after the episode’s publish date.


Discussion

Sign in or Join to comment or subscribe

2022-05-18T20:50:31Z ago

This episode resonated with me in so many ways. I have a small army of Raspberry Pis helping with some home automation tasks (which are mostly home monitoring at this point.) I’ll start with a quick description of my setup and add posts for other topics to avoid going too long going too long on this one.
I’m running Homeassistant in a Docker container on a Pi 3B with Mosquitto MQTT broker and MariaDB also in Docker containers. I’m using the 64 bit variant of R-Pi OS because (IIRC) I could not find a 32 bit ARM Docker image for MariaDB. I used to keep the MariaDB data store on a ZFS volume but a recent kernel upgrade caused the ZFS modules not to build. *I should consider moving this to a Pure Debian installation where stuff like this shouldn’t happen.) The CPU usage typically runs about 1-2% and free memory is about 570K. Of course, YMMV and my system only has about a half dozen MQTT messages/minute so traffic is pretty low. I suspect I would be memory constrained before I was CPU bound. And the system boots/runs from an SSD.
Regarding AWOL hosts (in my small army) I’ve started using the MQTT last will and testament facility so the broker reports if a host has not reported in a timely manner.

Refrigerator/freezer monitoring next.

2022-05-18T21:16:28Z ago

I’m monitoring both refrigerator and freezer. My firs try was with a commercial freezer alarm. It required a small wire to extend past the freezer gasket. The tiny opening this caused in the gasket resulted in ice buildup in the freezer. I tried unsuccessfully building up around the wire with achieve a better seal. I finally switched to a flat ribbon cable (truly flat, not like the old style ATA or floppy drive cables) to get past the door socket and connected to a DS18B20 sensor. The sensor is monitored by a Pi Zero W which published temperature via MQTT. Today I would use an ESP8266/ESP32 instead of a Pi. I constructed a similar arrangement for monitoring refrigerator temperature. I also monitor energy usage for both refrigerator and freezer using smart plugs that are queried by a Linux host and published via MQTT. I need to close the loop for these but in the mean time I can glance at a plot of temperature or power usage on the Homeassistant overview and see if everything is OK.

Jerod Santo

Jerod Santo

Omaha, Nebraska

Jerod co-hosts The Changelog, crashes JS Party, and takes out the trash (his old code) once in awhile.

2022-05-19T13:30:54Z ago

I finally switched to a flat ribbon cable (truly flat, not like the old style ATA or floppy drive cables) to get past the door socket and connected to a DS18B20 sensor.

Are you happy with these? Can you provide links to the ones you’re using?

Today I would use an ESP8266/ESP32 instead of a Pi.

Why is that? I got a Pi from a friend and am going to try to monitor our freezer like I said on the show…

2022-05-19T14:17:35Z ago

Here are the sensors. I used: https://smile.amazon.com/gp/product/B01IVMJ1L2/ They’ve been working for a couple years now with no problems. (*) I’ve also bought some of the waterproof ones but have not deployed them.
If you have a Pi already (hopefully one with WiFi) then use that. For a single task application the advantages I see for the ESP based devices include:

  • No need for an SD card (cost and reliability.)
  • No regular S/W updates required. I suppose if any of the libraries had a weakness, the app should be updated, but this should have a much smaller security exposure than something running a full blown OS.
  • Lower power usage.
  • Analog inputs: 1 on the ESP8266 and more on the ESP32.
  • Current availability - have you tried to buy a Pi recently?

Disadvantages

  • Higher bar to entry. I’ve been working on embedded systems (S/W) for decades so I’m pretty comfortable with this environment. But with something like ESPHome this application could probably be implemented with some simple configuration.

(*) No sensor problems, that is. I did have one setup malfunction due to a bad solder connection that separated.

2022-05-18T21:38:16Z ago

Other Pi tips:

  • Unless you need local storage, operate the Pi using the overlay filesystem (available in raspi-config settings.) Be sure to uninstall unattended-upgrades or your Pi will come to a grinding halt when the first apt update runs and fills the writable space in the overlay. If you do want some writable space, an additional partition will remain writable when the boot and root partitions are read only.
  • Pro tip: raspi-confiig can be run non-interactively so that the overlay can be disabled prior to running update/upgrade. It will still require reboots before and after the upgrade. Should allow this to be done using Ansible.
  • WiFi settings can be configured by putting wpa_supplicant.conf in the boot partition. touch ssh in the boot partition to enable ssh. Put a properly configured userconf.txt in the boot partition to specify the user and password to use. (The folk that produce the Pi OS have finally eliminated the default user/password in their images.) With these changes you can boot a Pi headless first time, ssh in and perform further configuration. (I’m not sure I can post links but the info for these should be easily found.)
  • With a properly routed jumper between GPIO pins and a momentary push button to a couple other pins, it is possible to initiate an orderly shutdown on the Pi and then cause it to reboot w/out interrupting power. This requires a little soldering. There is nothing scarier than a S/W engineer with a soldering iron, but soldering skills are occasionally useful. ;) This can be con with no code other than an entry in /boot/config.txt. I use
dtoverlay=gpio-shutdown,gpio_pin=7,active_low=1,gpio_pull=up 

Then I tie GPIO7 to GPIO3 and use a momentary push-button between GPIO7 and any convenient ground.

0:00 / 0:00