Chapter 18. Home Automation

18.0 Introduction

As a low-cost and low-power device, a Raspberry Pi makes a great home automation hub that you can leave running without fear of huge electricity bills. For the recipes described in this chapter, you don’t need the power of a Raspberry Pi 4 or 400. In fact, a Raspberry Pi 2 or 3 will be plenty fast enough and will run cooler and use less electricity than a Raspberry Pi 4.

We start with Message Queuing Telemetry Transport (MQTT), the basic communication mechanism for most home automation systems, and then move on to look at using Node-RED (which you first met in Chapter 17) as a basis for home automation.

Strictly speaking, home automation is all about making your home smarter and more able to do things for itself—for example, to turn on a light for a set amount of time when movement is detected, or to automatically turn everything off at bedtime. But most people who are interested in home automation are also interested in remote control of the parts of their home that have been automated. We also look at remote control by smartphone in this chapter.

18.1 Making a Raspberry Pi into a Message Broker with Mosquitto

Problem

You want to make your Raspberry Pi a hub for your home automation system capable of using the Mosquitto MQTT software.

Solution

Install the Mosquitto software so that your Raspberry Pi can act as an MQTT broker.

Run the following commands to install Mosquitto and start it as a service so that it automatically ...

Get Raspberry Pi Cookbook, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.