The Raspberry Pi 5 was recently announced. It is
faster than the old one, and you can add an SSD with a special adapter. The price went up, and
now it needs a beefy power supply. Is it worth ordering one for our home automation server?
Maybe you watch this video before you order.
Grüezi YouTubers. Here is the guy with the Swiss
accent. With a new episode and fresh ideas around sensors and microcontrollers. Remember: If you
subscribe, you will always sit in the first row.
I like the Raspberry Pi for its initial purpose.
Like many of us, I was lured into using it as a home server when it was still cheap and available.
During the shortage, I was forced to search for another solution and found this tiny second-hand
PC and Proxmox. Hardly more expensive, but way more useful and fun. And I discovered the value of
a Homelab. A vast improvement and a lot of fun!
This video is divided into three parts:
1. Teasing of the Homelab idea and show you my setup
2. Migration of Raspberry Pies to your Homelab
3. The creation of a new virtual machine with
all needed components, from reading sensors to displaying the results in nice-looking diagrams
(Mosquitto, Node-Red, influxDB, and Grafana)
And you will get a virtual machine with all the
examples for your new Homelab. Just in case you want to save time with your next project.
Let’s start with the Homelab. Why is it so much more fun to work with it?
- Everything is built in a nice and tidy case for a very decent price
- No more hassle with defective SD cards or slow SSDs
- More processing power and RAM
- And the most important: Proxmox, a free
and fantastic virtualization software
A Homelab with Proxmox extends
your possibilities a lot.
- Even a small PC can replace many
Raspberry Pies on one machine. This saves money, energy, and space.
- To create a new “Raspberry Pi” is a piece of cake. Just add a virtual
machine and install Debian on it. Done in a few minutes. Without any additional cost! If
you do not need it anymore, delete it and free all resources for your next experiment
- Backup and restore of virtual machines are simple and can be automated.
Like that, we do not forget it
- My favorite is “snapshots”. Before you
change something on your virtual machine, you take a snapshot. If you break something,
you just rewind to the snapshot and start over. Extremely cool and useful
- Of course, you cannot connect sensors directly to a Homelab. No big deal for
me because my sensors are not where my Homelab is. They are all over the place
But how can we upgrade from our Raspberry Pi to a Homelab?
First, we need a PC or a Mac. Typical sources for such devices are:
- Revive your old PC, Mac, or Laptop. It should have at least an SSD. Otherwise, it is no fun
- As I did in video #443, buy a used Thin Client PC. They are sold for cheap on the usual
platforms. This is my favorite solution
- Use your NAS if it is strong enough.
Saves money, space, and energy
- Buy one of these small PCs. They are sold
by the thousands to be used as firewalls. But they can do much more. If you are interested in
networking experiments, this is a good choice because they have a few 2.5GB Ethernet connectors
- Of course, you can go for a 19-inch server if you do not care about money and energy consumption
or if you want to show it off to your friends
My server only has 16GB of memory and
a 1TB disk. The 16GB is sufficient for most former Raspberry users. And 1TB is an
overkill for me. But I had it lying around.
Currently, I have 8 VMs on my Homelab. One
is Home Assistant, and two run Docker with many containers. If I run all of them, I still
have 3GB of free memory. You see, there are no problems with resources if you pay attention and
do not allocate too much memory. You must upgrade to a newer or bigger machine if you want more.
But before we continue, we must talk about why I use a second VM with containers on my Homelab.
1. I wanted to use Home Assistant mainly as a frontend and to integrate sensors. And I wanted
to use the operating system that comes with Home Assistant because I hope it will be the most
used and therefore create the least problems
2. I could have installed containers along
with Home Assistant on the same VM. Still, I decided against it because IOTstack is a
fantastic project that installs all kinds of Docker containers with all the glue between
them so that they work together without hassle. Phill and Slyke do an excellent job in supporting
the project as well as supporting you on Discord if you have problems. They recently adapted the
project so that it can easily be used on Proxmox
3. I want to be able to quickly create
a new installation for another purpose that does not need Home Assistant.
Later, I will show you such an example
As said, I use Home Assistant as a frontend
and for sensor integrations. All other things, particularly all automation, are done
in Node-Red. I use influxDB V2 as a database and Grafana for the display.
Now, we go on to step #2 and migrate our Raspberry Pis. Usually, this
is done with the following steps:
Next, I will lead you through these steps.
To install Proxmox on the new server, you will find all the information in
my video #443, including some tricks.
But how can we back up our current installation?
In Home Assistant, creating a Backup is easy. Go to Settings→System→Backups and
create a full backup. When done, download it to the download folder of your PC.
For IOTstack, things are under construction right now. I assume we will get a pair off
commands to create a full backup and a full restore on the Homelab. Please consult
Phills writeup when you do your migration.
So we are already at point #3: Installing Home
Assistant with its native operating system is simple. I leave a link in the description to
a video by Tinker Dad that shows how it is done. With Proxmox 8, you will no longer need
the trick he used at the end of his video.
So we are already at step 4: Creating a VM with
basic Debian on it. You could also use containers instead of a VM, but we chose to go this way.
You are covered by Phill’s writeup from phases 1 – 3. Maybe you want to create a template
VM now—another helpful feature of Proxmox. A template can be used to create many clones in the
future and save you time for a new installation.
Or you can create a snapshot of your VM. Just in
case something goes wrong. Then, you can always return to this point and start over.
Before we continue installing IOTstack, we insert the Zigbee USB dongle and add it
to our VM. Now, we can use it inside the VM for Zigbee2MQTT. Of course, you can add as
many USB devices as your application needs.
Next is step #6: The installation of
IOTstack. Follow Phill’s phases 4-6, and you are done. IOTstack should run now.
In step #7, we restore the data of Home Assistant. This is extremely simple because Home Assistant
offers this option at startup. Select the backup file from before, and you are good to go.
As said before, we should get a full_restore program that has to be run right after
script 5. Now, IOTstack is also ready.
In step #8, I recommend switching your
old Raspberries off and transferring their IP addresses to the new virtual
machines. Like that, all other devices in your network will continue to work.
And now comes step #9: Feel the speed of your new system. Change, for example, something
in Node-Red and deploy it. Mindboggling speed! There is still a big difference between
a Raspberry CPU and an Intel desktop.
And the best: You have one or two
Raspberries free for other projects and do not need to buy new ones. Cool!
I am pretty sure you will never look back!
In the second part of the video,
we will build a new installation of IOTstack and use the following example:
My remote radio station has a 7kWh battery, and I wanted to monitor its voltages
and currents from home. In addition, I wanted to switch the radio remotely on and
off. We will also need antenna switches and rotors to turn them in the future.
As shown in video #452, I created a network to the remote location using a 4G router
and Zerotier. I could have installed a Raspberry Pi at the remote site and connected to it from
home. But, because I wanted to keep complexity and power consumption low at the remote location,
I just added a VM to my Homelab. No additional hardware and no additional energy consumption.
What are the basic steps to running this rather complex system on my Homelab? Here are the steps:
- I used this project to read the BMS values. So we have to add the credentials of Mosquitto.
Now, the MQTT messages of the BMS flow via Mosquitto to Node-Red
- Mosquitto itself does not need any further setup
- We can go on to Node-Red. The MQTT receive node feeds a switch node to filter
the messages coming from the BMS. It only passes messages with the correct device name. Next
comes a “function node” that can be programmed using JavaScript. It takes the messages sent by
the ESP8266 and creates a message that can be stored in influxDB. Later, we will find these
values and the name of the “measurement” in influxDB. While adding an influxDB node, we
need a token. To create the token, we go to InfluxDB and create one. Easy-peasy.
- After deploying the Node-Red flow, we must add a bucket in influxDB. After a
few moments, we should see stored data coming from our ESP8266 in influxDBs Data Explorer
- Now, we can continue with the fun part and create nice-looking diagrams in Grafana. We
must go to “connections” and add an InfluxDB source. Here, you see how the fields are filled.
Also, here, we need a token from InfluxDB.
Here is a tip: Create a cheat sheet
with all the usernames, passwords, and tokens. It is much easier when you
return a few weeks later. I started to create a document for all my projects where
I noted all relevant credentials and some special commands. This saves me a ton of time.
- I will show you how to create a dashboard because it changed a lot from version 1
to 2 of influxDB. This query code looks complicated. Fortunately, it is automatically
created by influxDB. Just go back and select the fields you want to display in your
diagram. Hit “Submit”, and you can check if they look ok. Hit “Script Editor”, and you
can copy-paste the needed query. Cool! Just replace “v.windowPeriod” with 10 minutes or so to
aggregate your values. Another tip: In my browser, I keep three windows open: Node-Red, InfluxDB,
and Grafana. Like that, I can switch fast. Hit “Apply” and “Save”, and you are done.
- In my example VM, I also included a Node-Red dashboard for the radio operator.
Here, he sees the most critical data and can switch the radio on and off. The Node-Red flow
for the radio is quite simple and transmits MQTT messages to an ESP32 running ESPhome.
Now, our full-blown IOTstack example is finished.
Of course, I only scratched the surface of the
topics. But I hope you got an idea of how to proceed with your project. As promised,
I am providing you with the VM for my remote station as an example.
To import my demonstration VM, you download the backup file with the link in
the description. Then you transfer it to your Proxmox server into the directory /var/lib/vz/dump
using WinSCP and finally, go to the local disk on Proxmox and restore the VM. Now you can
use it as a reference to see how I did it.
Such examples can be precious because
I often return to my “old” projects to re-learn how I solved a problem.
Usually, this is easier than RTFM.
So, today, we learned:
- How much fun a Homelab can be and why I never looked back
- How to migrate our Raspberry Pi projects on our newly built Homelab
- If you want to start with a fresh Homelab, I showed you how to create an integrated
flow from an ESP8266 sensor to a nice-looking diagram in Grafana, including the storage
in influxDB and some logic in Node-Red
- I hope you can judge now if you need a
Raspberry Pi 5 or if you want to get a Homelab
- And because you get my VM, you
can feel the power of Proxmox: Just import it and see how all the details work
One last thing: Because Home Assistant is my front end, I also have a Fire tablet
displaying Home Assistant data in our kitchen and the Home Assistant app on my
iPhone. Maybe stuff for future videos…
That was all for today. As always, you find
all the relevant links in the description.
I hope this video was useful or at
least interesting for you. If true, please consider supporting the channel to
secure its future existence. Thank you! Bye