www.it-ebooks.info Raspberry Pi Home Automation with Arduino Automate your home with a set of exciting projects for the Raspberry Pi! Andrew K. Dennis BIRMINGHAM - MUMBAI www.it-ebooks.info Raspberry Pi Home Automation with Arduino Copyright © 2013 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 Production Reference: 1290113 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK ISBN 978-1-84969-586-2 www.packtpub.com Cover Image by William Kewley (william.kewley@kbbs.ie) www.it-ebooks.info Credits Author Andrew K. Dennis Reviewer Stefan Sjogelid Acquisition Editor Erol Staveley Commissioning Editor Ameya Sawant Technical Editors Veronica Fernandes Worrell Lewis Nitee Shetty Project Coordinator Joel Goveya Proofreader Stephen Swaney Indexer Hemangini Bari Graphics Valentina D'silva Aditi Gajjar Production Coordinator Shantanu Zagade Cover Work Shantanu Zagade www.it-ebooks.info About the Author Andrew K. Dennis is an R&D software developer at Prometheus Research. Prometheus Research is a leading provider of integrated data management for research and is the home of HTSQL, an open source navigational query language for RDMS. Andrew has a Diploma in Computing, a BS in Software Engineering, and is currently studying for a second BS in Creative Computing in his spare time. He has over 10 years experience working in the software industry in the UK, Canada, and the USA. This experience includes e-learning courseware development, custom CMS and LMS development, SCORM consultancy, web development in a variety of languages, open source application development, blogging about the integration of web technologies with electronics for home automation, and punching lots of Cat5 cables. His interests include web development, e-learning, 3D printing, Linux, the Raspberry Pi and Arduino, open source projects, home automation and the use of web technology in this sphere, amateur electronics, home networking, and software engineering. www.it-ebooks.info Acknowledgement I would like to thank my wife Megen for supporting me throughout this project and putting up with the piles of electronics and computer hardware dotted around the house. My parents, for their support with my interest in technology while growing up and over the subsequent years. The Cooking Hacks team, for their great new Raspberry Pi to Arduino Bridge shield and the various contributors over on the Cooking Hacks forum for their insights. The people at Prometheus Research, for making this a great and interesting place to work. Partyka Chevrolet, for giving me some experience on the hardware side of networking. I would also like to thank Joel Goveya and Ameya Sawant at Packt Publishing for their guidance throughout this process, and Stefan Sjogelid for his technical insights and reviews. www.it-ebooks.info About the Reviewer Stefan grew up in the 1980s with the C64 and the Amiga home computers. The ambitious goal of the Raspberry Pi Foundation, bringing fun programming back to today's youth, resonated strongly with Stefan who immediately ordered his Raspberry Pi on the launch day itself. After much tinkering and learning a great deal about the unique properties of the Pi, he launched the "PiLFS" (http://www.intestinate.com/pilfs) website, which teaches readers how to build their own GNU/Linux distribution and applications that are particularly useful on the Raspberry Pi. www.it-ebooks.info www.PacktPub.com Support les, eBooks, discount offers and more You might want to visit www.PacktPub.com for support les and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub les 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 service@packtpub.com for more details. 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. TM http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across 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 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 nine entirely free books. Simply use your login credentials for immediate access. www.it-ebooks.info www.it-ebooks.info Table of Contents Preface 1 Chapter 1: An Introduction to the Raspberry Pi, Arduino, and Home Automation 7 What we will explore in this book 7 History and background of the Raspberry Pi 8 Raspberry Pi hardware specications 9 Dimensions 10 3.5mm analog audio jack 10 Composite RCA port 10 Two USB 2.0 ports plus one micro USB 10 HDMI port 11 SD card port 11 256 MB/512 MB SDRAM shared with GPU 11 CPU 11 GPU 11 Ethernet port 12 GPIO pins 12 History and background of Arduino 12 Raspberry Pi to Arduino shield connection bridge 13 Shield specications 13 XBee socket 14 Power source selector 14 UART 14 Digital GPIO pins 14 Serial Peripheral Interface (SPI) pins 15 In Circuit Serial Programmer (ICSP) connector 15 Power pins 15 Analog inputs 15 Raspberry Pi GPIO connector 15 www.it-ebooks.info [...]... which send an analog signal to the shield This is the analog counterpart of the digital GPIO pins described earlier Raspberry Pi GPIO connector The Raspberry Pi GPIO connector can be found on the bottom of the shield This is where you will connect your Raspberry Pi to Arduino bridge shield to the Raspberry Pi' s GPIO pins Soldering Soldering is the process of attaching electronic components together using... Introduction to the Raspberry Pi, Arduino, and Home Automation, introduces you to the technologies used in this book and provides a background to the world of home automation Chapter 2, Getting Started Part 1 – Setting up Your Raspberry Pi, teaches you about the Raspberry Pi and how to set it up, ready to use on your projects Chapter 3, Getting Started Part 2 – Setting up Your Raspberry Pi to Arduino Bridge... Ethernet port is the Raspberry Pi' s main gateway to communicating with other devices and the Internet You will be able to use the Ethernet port to plug your Raspberry Pi into a home router such as the one you currently use to access the Internet, or a network switch if you have one set up GPIO pins The General Purpose Input/Output (GPIO) pins on the Raspberry Pi are the main way of connecting with other electronic... 29 Hooking up the Raspberry Pi Downloading the right operating system Installing Raspbian Installation complete Windows users Mac and Linux users 29 30 31 34 35 36 Summary 37 Chapter 3: Getting Started Part 2 – Setting up Your Raspberry Pi to Arduino Bridge Shield Raspberry Pi to Arduino bridge shield Checking which version of the Raspberry Pi we have Setting up the Raspberry Pi to Arduino shield and... pointed to our database and then query it without having to write further server-side code Now that we have looked at our tools for building home automation systems, the Raspberry Pi and Arduino, lets look at what home automation is [ 16 ] www.it-ebooks.info Chapter 1 What home automation is Having picked up this book, you may already have an idea of what home automation is, but just in case, we'll give... as with personal computing, that saw the birth of the modern era of home automation technology [ 17 ] www.it-ebooks.info An Introduction to the Raspberry Pi, Arduino, and Home Automation X10 – a standard is born The beginning of modern home automation technology can be argued to be found with the introduction of the X10 technology standard Conceived in 1975 by Pico Electronics, who later partnered with. .. upon a program running on the Raspberry Pi' s operating system Having touched upon the technical capabilities of the Raspberry Pi, we will now look at the Arduino and the Raspberry Pi to Arduino shield, a way to connect the two technologies via the GPIO pins History and background of Arduino One of the most popular open source hardware products to have hit the market is the Arduino platform – a branch... boards, the Raspberry Pi will fulfill this role However we will be using the Raspberry Pi to Arduino shield This will allow us to connect shields and other components to the Raspberry Pi and control them via the Arduino programming language Raspberry Pi to Arduino shield connection bridge For our project, the particular Raspberry Pi to Arduino shield we will be using is produced by Cooking Hacks, an offshoot... connected to the Raspberry Pi' s GPIO pins, and with the inclusion of the arduPi software, you will be able to communicate between your electronic devices, the Raspberry Pi' s operating system, and web-based projects Let's take a quick look at the shield and its components Shield specifications The Raspberry Pi to Arduino shield is a credit card sized electronics board that mimics an Arduino microcontroller... introduction to the Raspberry Pi, Arduino, and the subject of home automation We'll look at the history of the Raspberry Pi and how it came to be, as well as the Arduino platform – an open source microcontroller that provides developers with a means to interact with their surroundings, through a variety of sensors and motors Finally, we will wrap up the chapter by covering home automation and how technologies . www.it-ebooks.info Raspberry Pi Home Automation with Arduino Automate your home with a set of exciting projects for the Raspberry Pi! Andrew K. Dennis BIRMINGHAM. to the Raspberry Pi, Arduino, and Home Automation 7 What we will explore in this book 7 History and background of the Raspberry Pi 8 Raspberry Pi hardware