Book Image

Building a Home Security System with Raspberry Pi

By : Matthew Poole
Book Image

Building a Home Security System with Raspberry Pi

By: Matthew Poole

Overview of this book

The Raspberry Pi is a powerful low-cost credit-card-sized computer, which lends itself perfectly as the controller for a sophisticated home security system. Using the on-board interfaces available, the Raspberry Pi can be expanded to allow the connection of a virtually infinite number of security sensors and devices. The Raspberry Pi has the processing power and interfaces available to build a sophisticated home security system but at a fraction of the cost of commercially available systems. Building a Home Security System with Raspberry Pi starts off by showing you the Raspberry Pi and how to set up the Linux-based operating system. It then guides you through connecting switch sensors and LEDs to the native GPIO connector safely, and how to access them using simple Bash scripts. As you dive further in, you’ll learn how to build an input/output expansion board using the I2C interface and power supply, allowing the connection of the large number of sensors needed for a typical home security setup. In the later chapters of the book, we'll look at more sophisticated topics such as adding cameras, remotely accessing the system using your mobile phone, receiving intrusion alerts and images by e-mail, and more. By the end of the book, you will be well-versed with the use of Raspberry Pi to power a home-based security system that sends message alerts whenever it is triggered and will be able to build a truly sophisticated and modular home security system. You will also gain a good understanding of Raspberry Pi's ecosystem and be able to write the functions required for a security system.
Table of Contents (16 chapters)
Building a Home Security System with Raspberry Pi
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

The Raspberry Pi is a powerful, low-cost, credit-card sized computer, which lends itself perfectly as the controller of a sophisticated home security system. Using the available on-board interfaces, the Raspberry Pi can be expanded to allow the connection of a virtually infinite number of security sensors and devices. The Raspberry Pi has the processing power and interfaces available to build a sophisticated home security system but at a fraction of the cost of commercially available systems.

Building a Home Security System with Raspberry Pi starts off by showing you the Raspberry Pi and how to set up the Linux-based operating system. The book then guides you through connecting switch sensors and LEDs to the native GPIO connector safely, and it also shows you how to access these using simple Bash scripts. As you dive further in, you'll learn how to build an input/output expansion board using the I2C interface and power supply, allowing the connection of the large number of sensors needed for a typical home security setup.

The book features clear diagrams and code listing every step of the way to allow you to build a truly sophisticated and modular home security system.

What this book covers

Chapter 1, Setting Up Your Raspberry Pi, starts out by taking our Raspberry Pi out of its box and preparing it for being the centerpiece of our home security system. Along the way, we will install and set up the operating system, connect our Pi to the network, and access it remotely. We'll also secure our Pi and make sure it can keep the right time.

Chapter 2, Connecting Things to Your Pi with GPIO, explores the GPIO port and the various interfaces it features. We'll look at the various things we can connect to the Raspberry Pi using the GPIO including switches and sensors as we start to build our home security system.

Chapter 3, Extending Your Pi to Connect More Things, looks at ways of expanding the number of things we can connect to our Raspberry Pi, overcoming the limitation of having just the eight digital pins available to us on the GPIO by tapping into other interfaces on the GPIO and building our own input/output expansion board.

Chapter 4, Adding a Magnetic Contact Sensor, starts to actually connect things to our home security system, such as magnetic sensors and other types of contact devices. You will learn how to program our I2C expansion port using Bash scripts so that we can read the state of our sensors and switch on warning LEDs. We'll also start to develop the control scripts for our system that will allow us to arm and disarm the system and add delay timers.

Chapter 5, Adding a Passive Infrared Motion Sensor, looks at passive infra-red motion detectors, how they work, and how we can connect wired and wireless types to our home security system. We'll also learn how to create log files based on events using Bash scripts so that we can maintain a history of detector states as they change.

Chapter 6, Adding Cameras to Our Security System, teaches you how to connect both Raspberry Pi camera modules and USB cameras to our Pi board in order to take image and video captures when required by our home security system. We'll also learn how to overlay our images with informative text and have the files immediately emailed to us.

Chapter 7, Building a Web-Based Control Panel, gets down to the business of starting to put together modules by building a mobile-optimized web-based control panel for our home security system. You'll learn how to set up a web server on our Raspberry Pi and manipulate files using our web control panel, meaning we'll start to explore how all of the elements so far will come together as part of our final system.

Chapter 8, A Miscellany of Things, looks a few other bits and pieces, such as adding other sensors to our home security system that are not necessarily related to intruder detection. We'll also look at how we can administer our entire Raspberry Pi system remotely using a web browser in addition to accessing our home security control panel.

Chapter 9, Putting It All Together, is the moment we've all been waiting for; we're going to take all of the elements and concepts from the previous chapters and put together our full system comprising the elements we want to feature. The star of the show will be our Bash scripts, which will glue together all of these elements and provide the control logic for the entire system.

What you need for this book

You'll need the following software:

  • Gparted dd fake-hwclock

  • Win32 Disk Imager 0.9.5 PuTTY

  • i2c-tools

Who this book is for

This book is for anyone who is interested in building a modular home security system from scratch using a Raspberry Pi board, basic electronics, sensors, and simple scripts. This book is ideal for enthusiastic novice programmers, electronics hobbyists, and engineering professionals. It would be great if you have some basic soldering skills in order to build some of the interface modules.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Extract 2015-09-24-raspbian-jessie.img to your Home folder."

A block of code is set as follows:

# passwd
root@raspberrypi:/home/pi# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@raspberrypi:/home/pi#

Any command-line input or output is written as follows:

$ sudo apt-get install fake-hwclock

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Type the IP address of the Raspberry Pi into the Host Name box and click on Open."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.