Raspberry Pi Home Automation with Arduino - Second Edition
()
About this ebook
- Revolutionize the way you automate your home by combining the power of the Raspberry Pi and Arduino
- Build simple yet awesome home automated projects using an Arduino and the Raspberry Pi
- Learn how to dynamically adjust your living environment with detailed step-by-step examples
If you are new to the Raspberry Pi, the Arduino, or home automation and wish to develop some amazing projects using these tools, then this book is for you. Any experience in using the Raspberry Pi would be an added advantage.
Read more from Dennis Andrew K.
Raspberry Pi Super Cluster Rating: 0 out of 5 stars0 ratingsRaspberry Pi Computer Architecture Essentials Rating: 0 out of 5 stars0 ratings
Related to Raspberry Pi Home Automation with Arduino - Second Edition
Related ebooks
Raspberry Pi Robotic Projects - Third Edition Rating: 0 out of 5 stars0 ratingsArduino Home Automation Projects Rating: 3 out of 5 stars3/5Building Wireless Sensor Networks Using Arduino Rating: 4 out of 5 stars4/5Arduino Android Blueprints Rating: 0 out of 5 stars0 ratingsArduino Networking Rating: 4 out of 5 stars4/5Arduino for Secret Agents Rating: 4 out of 5 stars4/5Arduino by Example Rating: 4 out of 5 stars4/5Getting Started with Raspberry Pi Zero Rating: 5 out of 5 stars5/5Internet of Things with ESP8266 Rating: 5 out of 5 stars5/5Arduino Electronics Blueprints Rating: 4 out of 5 stars4/5Learning Raspbian Rating: 5 out of 5 stars5/5Arduino Robotic Projects Rating: 4 out of 5 stars4/5Python Programming for Arduino Rating: 5 out of 5 stars5/5Raspberry Pi: The complete guide to Raspberry Pi for beginners, including projects, tips, tricks, and programming Rating: 0 out of 5 stars0 ratingsRaspberry Pi: Amazing Projects from Scratch Rating: 0 out of 5 stars0 ratingsInternet of Things with Arduino Blueprints Rating: 0 out of 5 stars0 ratingsLearning C for Arduino Rating: 0 out of 5 stars0 ratingsArduino Essentials Rating: 5 out of 5 stars5/5Raspberry Pi for Secret Agents Rating: 4 out of 5 stars4/5Arduino: Building LED and Espionage Projects Rating: 0 out of 5 stars0 ratingsRaspberry Pi for Secret Agents - Third Edition Rating: 0 out of 5 stars0 ratingsRaspberry Pi | 101 Rating: 0 out of 5 stars0 ratingsBuilding Smart Homes with Raspberry Pi Zero Rating: 0 out of 5 stars0 ratingsRaspberry Pi :Raspberry Pi Guide On Python & Projects Programming In Easy Steps Rating: 3 out of 5 stars3/5Raspberry Pi Server Essentials Rating: 0 out of 5 stars0 ratingsLearn Arduino Prototyping in 10 days Rating: 0 out of 5 stars0 ratingsSmart Internet of Things Projects Rating: 4 out of 5 stars4/5Raspberry Pi Robotics Essentials Rating: 0 out of 5 stars0 ratingsRaspberry Pi Android Projects Rating: 0 out of 5 stars0 ratings
Programming For You
Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Hacking: Ultimate Beginner's Guide for Computer Hacking in 2018 and Beyond: Hacking in 2018, #1 Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 0 out of 5 stars0 ratingsLearn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5OneNote: The Ultimate Guide on How to Use Microsoft OneNote for Getting Things Done Rating: 1 out of 5 stars1/5SQL: For Beginners: Your Guide To Easily Learn SQL Programming in 7 Days Rating: 5 out of 5 stars5/5PYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5TensorFlow in 1 Day: Make your own Neural Network Rating: 4 out of 5 stars4/5Learn SQL in 24 Hours Rating: 5 out of 5 stars5/5C# 7.0 All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsPython: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5Python Data Structures and Algorithms Rating: 5 out of 5 stars5/5Python QuickStart Guide: The Simplified Beginner's Guide to Python Programming Using Hands-On Projects and Real-World Applications Rating: 0 out of 5 stars0 ratingsUnity from Zero to Proficiency (Beginner): Unity from Zero to Proficiency, #2 Rating: 5 out of 5 stars5/5C++ Learn in 24 Hours Rating: 0 out of 5 stars0 ratings
Reviews for Raspberry Pi Home Automation with Arduino - Second Edition
0 ratings0 reviews
Book preview
Raspberry Pi Home Automation with Arduino - Second Edition - Dennis Andrew K.
Table of Contents
Raspberry Pi Home Automation with Arduino Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. An Introduction to the Raspberry Pi, Arduino, and Home Automation
History and background of the Raspberry Pi
History and background of the Arduino
Raspberry Pi to Arduino shield connection bridge
Soldering
Creating software for the Arduino
What is home automation?
History of home automation
X10 – a standard is born
The dot-com boom and open source – a new set of technologies
Commercial products
Arrival of the Raspberry Pi
Summary
2. Getting Started – Setting Up Your Raspberry Pi and Arduino
The SD card – our Raspberry Pi's storage device
Preinstalled SD card versus a blank SD card
A note on Noobs
Downloading Raspbian
Setting up the SD card and installing Raspbian
Raspberry Pi SSH setup
Arduino
Installing the IDE on your Raspberry Pi
A quick guide to the Arduino IDE
Using the Arduino to Raspberry Pi connection bridge
Summary
3. Central Air and Heating Thermostat
Safety first
Introducing the thermostat
Setting up our hardware
Adding the Ethernet shield
Relays
Connecting the thermistor
Setting up our software
Thermostat software
Testing our thermostat and fan
Attaching the fan
Starting your thermostat application
Testing the JSON response
Next steps
Attaching the device to your heating system or a similar appliance
Adding a potentiometer
Adding an LCD screen
Summary
4. Temperature Storage – Setting Up a Database to Store Your Results
SSH
SQLite
Installing SQLite Version 3.x
Creating a database
A table to record our temperature
A table to record our rooms
Writing SQL queries
Creating a Python application to write to our database
Checking the results
Adding a cron job
HTSQL
Downloading HTSQL
Configuring HTSQL
Summary
5. Parcel Delivery Detector
Wiring up the parcel sensor
An introduction to resistors
Pressure sensor – force-sensing resistor
10K ohm resistor
Connecting the components to the Arduino
Writing our software
Updating the Raspberry Pi database
A web-based Python application
Setting up SMTP
Our Python application
Starting the web service
Testing our application
Installing the parcel detector
Testing the complete setup
Next steps
Upgrading from Ethernet to a wireless system
Checking the shipping details
Replacing the pressure sensor with a camera and image recognition
Summary
6. Curtain Automation – Open and Close the Curtains Based on the Ambient Light
Introduction to the Arduino bridge shield
Installing arduPi
Photoresistors
Motor shield and motors
Setting up the photoresistor
Wiring up the components
Testing the photoresistor with software
Makefiles
Setting up the motor shield
Wiring the components to the shield
Curtain control application
Pulse width modulation
Threads
Writing our code
Connecting to your blinds/curtains
Setting the timing
Attaching the hardware
Debugging problems
Next steps
Mounting the photoresistor outdoors
Adding a stepper motor
Summary
7. Water/Damp Detection – Check for Damp/Flooding in Sheds and Basements
A brief note on dampness
Damp detection system
Arduino circuit
Sketch code
Database updates
Python code
Adding a cron job
Using the humidity reading
Adding an LED alert
Blinking LED code
Expanding the LED functionality
Connecting a dehumidifier
Water detection
Summary
8. Wrapping Up
A brief review of the second edition of Raspberry Pi Home Automation with Arduino
Next steps
The prototyping Pi Plate
The wiringPi library
The Gertboard
Introduction to the Gertboard components
GPIO PCB expansion board
GPIO pins
Motor controller
The open collector drivers
Buffered I/O
Atmel ATmega microcontroller
Convertors – analog to digital and digital to analog
Creating software for the Gertboard
Ideas for future projects
Expanding the curtain automation tool to include temperature sensing
Changing the motor on the curtain automation project to a stepper motor
Switching lights on with a photoresistor
Holiday lights from LEDs
The future of home automation
3D printing
RFID chips
EEG headsets
Summary
A. References
Raspberry Pi
Raspberry Pi to Arduino bridge shield
Linux
Python
C/C++
Arduino
SQL
HTSQL
Electronics
Packt Publishing titles
Home automation technology
3D printing
Index
Raspberry Pi Home Automation with Arduino Second Edition
Raspberry Pi Home Automation with Arduino Second Edition
Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: February 2013
Second edition: February 2015
Production reference: 1200215
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78439-920-7
www.packtpub.com
Credits
Author
Andrew K. Dennis
Reviewers
Ed Baker
Rémy Bétus
Piotr Kula
Commissioning Editor
Akram Hussain
Acquisition Editor
Richard Brookes-Bland
Content Development Editor
Prachi Bisht
Technical Editor
Mitali Somaiya
Copy Editor
Vikrant Phadke
Project Coordinator
Shipra Chawhan
Proofreaders
Simran Bhogal
Chris Smith
Indexer
Mariammal Chettiyar
Production Coordinator
Melwyn D'sa
Cover Work
Melwyn D'sa
About the Author
Andrew K. Dennis is the manager of professional services software development at Prometheus Research. This company is a leading provider of integrated data management for research, and is the home of HTSQL, an open source navigational query language for RDBMS.
Andrew has a diploma in computing and a BS in software engineering. He is currently studying for a second BS in creative computing.
He has over 10 years of experience in the software industry in the UK, Canada, and USA. His experience includes Python and JavaScript development, e-learning, CMS and LMS development, SCORM consultancy, web development in a variety of languages, open source application development, and a blog dedicated to maker culture and home automation.
His interests include web development, e-learning, 3D printing, Linux, the Raspberry Pi and Arduino, open source projects, parallel computing, home automation, amateur electronics, home networking, and software engineering.
Many of these topics were covered in his previous book, Raspberry Pi Super Cluster, Packt Publishing.
I would like to thank my wife, Megen, for supporting me throughout this project, and my parents for their support with my interest in technology while I was growing up.
I would also like to thank the team at Prometheus Research for making this a great and interesting place to work and helping to change the face of data management.
Finally, I would like to thank everyone who bought the first edition of this book, and the team at Packt Publishing for commissioning this second edition.
About the Reviewers
Ed Baker graduated with a BSc in Physics from Imperial College in 2007, and somehow ended up working in the Entomology Department of The Natural History Museum shortly afterwards. His work focuses on how technology (both hardware and software), can improve the way research is performed, from field data collection to final publication. Outside the technology world, he is fond of stick insects, cockroaches, and grasshoppers.
Recently, Ed's work has focused on automated acoustic and environmental monitoring and protocols for sensor networks. He has started a biodiversity technology company called Infocology.co.uk.
Ed's first book, provisionally titled Arduino for Biologists, will be published in 2015 with Pelagic Publishing.
I would like to thank Philippa for believing that writing and tinkering would bring rewards in the end.
Rémy Bétus is a web developer in e-commerce, and he integrates open source solutions. He's always been an enthusiast on the Arduino, the Raspberry Pi, and other DIY products. He was also a member of the Fablab in his engineering school, where he discovered all of these wonderful things. He is also passionate about development, networks, telecommunication, and science in general.
www.PacktPub.com
Support files, eBooks, discount offers, and more
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Free access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
Preface
The world of home automation is an exciting field that has exploded over the past few years with many new technologies in both the commercial and open source worlds. This book provides a gateway for those interested in learning more about this topic and building their own projects.
With the introduction of the Raspberry Pi computer in 2012, a small and powerful tool is now available for the home automation enthusiast, programmer, and electronic hobbyist. It allows them to augment their home with sensors and software.
Combining Raspberry Pi with the power of the open-hardware Arduino platform, this book will take you through several projects in which you will build electronic sensors, and introduce you to software that will record their data for later use.
We hope you will enjoy the second edition of Raspberry Pi Home Automation with Arduino.
What this book covers
Chapter 1, An Introduction to the Raspberry Pi, Arduino, and Home Automation, introduces the technologies used in the book and provides a conceptual background to the world of home automation.
Chapter 2, Getting Started – Setting Up Your Raspberry Pi and Arduino, is a