Join Johnny as he dives into the world of home automation with Ricardo Gerardi & Mike Riley, two tinkerers whoāve taken the plunge with Go. We explore the challenges (and the fun) they encounter along the way. If youāre interested in automating your home (or working with micro controllers) come learn how to get started!
Mike Riley: Well, Iāll start, and then Ricardo, you can certainly embellish further⦠So yeah, the Piās - theyāre in various configurations. These days you can get up to a Raspberry Pi 5, which is the most powerful. Unfortunately, itās also the most expensive. Myself, Iām still fairly comfortable with the Raspberry Pi 4, especially the 8-gig model. Itās got plenty of RAM, itās got plenty of CPU capacity, especially for the smaller jobs. And again, because Go is so small of a footprint, it doesnāt take a lot of resources to run.
[00:12:11.04] So you can run multiple Go applications, within containers no less, on a single Raspberry Pi. And thatās what Iām doing. Iāve got a Raspberry Pi cluster right now thatās doing a number of the jobs that weāve written for the book. Now, in the book we didnāt want to make it more complex and add Kubernetes to the mix, because thatās a whole other book in and of itself. So weāve instead recommended that people build their Docker containers and then run it within a Docker container. But needless to say, even running within a Docker container, we can run multiple ā in fact, we can run all the projects in the book on a single Raspberry Pi, if necessary.
So obviously, get yourself a Raspberry Pi. You do have to know a little bit of Linux, a little bit of command line. Of course, thereās tons of books, as well as videos and everything else out there for that. And itās fairly easy to get up to speed, even if itās basic command line. And we do provide all the command lines necessary, although, again, it really helps to have some background, a little bit of experience with them.
Once youāve got the Go SDK installed on your Pi, the skyās the limit. If you already know Go, you can go ahead and start building programs right then and there. Now, there is an extension library specifically written for the Pi, that allows you to access the GPIO pins, which is the reader pins, the header pins on the Pi, as well as the built in LED, so that you can blink that as well.
Now, one of the really cool things that Iām really, really pleased about in the book, and it really didnāt come until the very last minute, was the fact that we were able to use TinyGo. And TinyGo is a specifically designed subset of Go, that is designed specifically for embedded devices. Now, you could, I suppose, run TinyGo on the Pi, but the Pi has got plenty of resources. Iām talking more about the new Pi Zero, which is an embedded device really just for ā kind of like an Arduino in a way, in that itās specifically purpose-built for being able to pick up sensors, or control actuators. And what that really does - and for us, in a way - is one of the nice things of Pi Zero⦠In fact, you really want to get the Pi Zero W, which is the Wi-Fi edition. Because thereās two models. Wi-Fi is only like two bucks more, so itās definitely worth it. But it allows you to put that anywhere you can get a Wi-Fi signal.
And in fact, this kind of fulfilled that dream that I talked about earlier, with the Changelog folks. One of the hosts had mentioned that they wanted to find a way to monitor their freezer, because it was having some issues, and they didnāt want to wake up one morning and discover that their food had spoiled. So I thought about that problem and weāve actually solved that problem in the book.
So you can simply get a Pi Zero, you build a TinyGo program, install it on that Pi Zero, and the Pi Zero will then not only connect to the Wi-Fi, but using the onboard temperature probe on the board, you can then capture in real time what the ambient temperature is around. You tie that into the ability to export that result as a JSON format, consume that in Prometheus, and then Prometheus can provide that to Grafana, so youāve got a full real-time map for as long as you want it. If you want it for two weeks, two months, whatever; you set the parameters. But now youāve got a complete fluctuation, or ā what I use it for is internal monitoring of my temperature, because Iāve got different temperature zones in the home. So I can see, as the day comes, you get the cyclic cycles, and itās really kind of neat to see how that happens.
[00:16:00.14] But I also have it so that if that temperature starts to hit a threshold, I then tie into Grafanaās alerting capabilities, so that it contacts myself. And if you do decide to go with the Grafanaās free cloud version, theyāve got another add-on feature for incident management called OnCall. And it actually saved my bacon once, because we had a pretty brutal winter here, where the heater went down, and I didnāt know about it because I was away at the time. But then all of a sudden I get these alerts saying āYouāve got a problem.ā And fortunately, Iāve got my kids on the OnCall as a backup. And so theyāre like āHey, dad, I think thereās a problem with the heater.ā Iām like āYeah, there sure is.ā Fortunately, we ā