Book Image

Building Smart Homes with Raspberry Pi Zero

By : Marco Schwartz
Book Image

Building Smart Homes with Raspberry Pi Zero

By: Marco Schwartz

Overview of this book

The release of the Raspberry Pi Zero has completely amazed the tech community. With the price, form factor, and being high on utility—the Raspberry Pi Zero is the perfect companion to support home automation projects and makes IoT even more accessible. With this book, you will be able to create and program home automation projects using the Raspberry Pi Zero board. The book will teach you how to build a thermostat that will automatically regulate the temperature in your home. Another important topic in home automation is controlling electrical appliances, and you will learn how to control LED Lights, lamps, and other electrical applications. Moving on, we will build a smart energy meter that can measure the power of the appliance, and you’ll learn how to switch it on and off. You’ll also see how to build simple security system, composed of alarms, a security camera, and motion detectors. At the end, you will integrate everything what you learned so far into a more complex project to automate the key aspects of your home. By the end, you will have deepened your knowledge of the Raspberry Pi Zero, and will know how to build autonomous home automation projects.
Table of Contents (17 chapters)
Building Smart Homes with Raspberry Pi Zero
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Controlling the speed of a DC motor


In any smart home, chances are you will find a DC motor somewhere that you will need to automate. It could, for example, be on electric window blinds, or on an automated garage door. In this section, we are going to see how to control the speed of a simple DC motor and you will then be able to apply this to any motors you already have in your home.

Let's first see how to connect the DC motor to your Raspberry Pi Zero board. We actually won't connect the motor directly to the Raspberry Pi, as this would require a lot of external components, such as transistors, diodes, and so on. Instead, we'll use the L293D chip, which is a dedicated IC to control DC motors.

First, place the L293D on the board. The following diagram shows the pinout of the L293D:

You basically need to connect the components to the L293D as follows:

  • GPIO14 of the Raspberry Pi to pin 1A

  • GPIO15 of the Raspberry Pi to pin 2A

  • GPIO18 of the Raspberry Pi to pin 1,2EN

  • DC motor to pin 1Y and 2Y

  • 5V of the...