Intro to Raspberry Pi Home Automation
October 29, 2020
Home automation, and the Internet of Things, has been the technology of the near future for what seems like well over a decade now.
Image Credit: Jeremy S. Cook
Home automation, and the Internet of Things, has been the technology of the near future for what seems like well over a decade now. As it turns out, however, the idea that every appliance needs to connect to the net, to order new cartridges for the coffee maker or schedule maintenance, has yet to be widely adopted. Nor has the concept of having lights and other appliances come on at just the right time, according to a cloud-based service and sensor setup, you more than likely have to flip a switch the old-fashioned way.
While all of this is interesting from a technical standpoint, there are some real drawbacks. First, the Internet does go down from time to time (either on your end, or “the cloud’s”), yet you still need to operate the “things,” such as lights and air conditioning. It’s also generally less convenient to get out your phone or a central remote than to flip a switch, and there are some obvious privacy and lock-in issues.
What’s needed, in my opinion, is a system that is hosted on-site, with a variety of devices that can be programmed and controlled as needed, without being locked into one vendor. Also, it should use your existing WiFi setup. Sound too good to be true? In fact, I’ve been able to test two separate systems doing so, that can run on a $40-ish Raspberry Pi and control a variety of devices.
The first system tested is known as openHAB (open Home Automation Bus) and the second is simply called Home Assistant (HA). I chose openHAB to begin with for no other reason than it was what was on my mind at the time, however, I found it to have a steep learning curve. To be fair, openHAB doesn’t make any claims to the contrary.
ESP8266 garage controller, an earlier iteration of which is outlined here.
Image Credit: Jeremy S. Cook
After a conversation with a much more experienced programmer, the sense that I got was that while opehHAB is extremely powerful, HA might be easier to implement. After some thought, I instead loaded up HA on my Raspberry Pi, which I found to be easier to implement, especially given my rather modest home automation goals. To be fair, much of the work that I did on the front end to set up my devices appropriately certainly made it easier.
System and Setup Overview
As of now I have my garage controlled via HA, along with a fountain on my front porch, both using ESP8266-controlled relays. I can also control my Roku player from the home automation smartphone interface, which was a nice bonus, and an ability that Home Assistant auto-detected for me.
The trick here is that each of these smart switches was programmed with a custom piece of firmware called “Tasmota,” which facilitates, local instead of cloud control and integrates nicely with HA. For very simple applications, you don’t even technically need to be running HA or openHAB to take advantage of this new functionality, as it puts up its own local website. I’ll go into more detail about firmware flashing and setup in an upcoming post.
Bonus control of Roku auto-detected!
Image Credit: Screencap
The second part of a DIY home automation integration is the system itself. Mine is running on a Raspberry Pi 4, and directly connected to my router with an Ethernet cable. This requires some configuration, which I’ll also outline later, involving flashing an SD card and connecting things using MQTT.
It’s been a bit of a journey so far, but I’m really only scratching the surface of what can be done. Consider yourself warned, once you have this new ability of custom automation, it may be hard to stop. For now, you might check out the video below to see a comparison between Home Assistant and OpenHAB, as it will be one of the first decisions you’ll have to make when getting started:
Per that presentation, it seems that HA has the edge, but both are competent systems. The HA ease of use advantage is a big one for me, and it seems to have a more active community, which could also be important. It took me around 6 months of on-and-off work to get to the rather basic setup I have now, though it would be a much shorter process if I had to do it over again!
Jeremy S. Cook is a freelance tech journalist and engineering consultant with over 10 years of factory automation experience. An avid maker and experimenter, you can follow him on Twitter [https://twitter.com/JeremySCook], or see his electromechanical exploits on the Jeremy S. Cook YouTube Channel! [https://www.youtube.com/c/jeremyscook]