ebook img

Raspberry Pi: Amazing Projects from Scratch PDF

567 Pages·2016·18.2 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Raspberry Pi: Amazing Projects from Scratch

Raspberry Pi: Amazing Projects from Scratch Explore the powers of Raspberry Pi and build your very own projects right out of the box A course in three modules BIRMINGHAM - MUMBAI Raspberry Pi: Amazing Projects from Scratch Copyright © 2016 Packt Publishing All rights reserved. No part of this course 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 course to ensure the accuracy of the information presented. However, the information contained in this course is sold without warranty, either express or implied. Neither the authors, 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 course. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this course by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Published on: September 2016 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78712-849-1 www.packtpub.com Preface Machine learning and predictive analytics are becoming one of the key strategies for unlocking growth in a challenging contemporary marketplace .It is one of the fastest growing trends in modern computing and everyone wants to get into the field of machine learning. In order to obtain sufficient recognition in this field, one must be able to understand and design a machine learning system that serves the needs of a project. The idea is to prepare a Learning Path that will help you to tackle the real- world complexities of modern machine learning with innovative and cutting-edge techniques. Also, it will give you a solid foundation in the machine learning design process, and enable you to build customized machine learning models to solve unique problems What this learning path covers Module 1, Raspberry Pi By Example, provides you an introduction to the Raspberry Pi. It helps in building games with PyGame and creation of real-life applications with the Raspberry Pi. It further demonstrates the GPIO and cameras with advanced concepts in OpenCV. This module further delves with setting up a web server and creating network utilities. Module 2, Building a Home Security System with Raspberry Pi, lets you explore the GPIO Port along with building input/ output expansion board which helps in overcoming the limitations on GPIO. It helps you to create log files based on events using Bash Scripts. This module further covers a miscellany of things for accessing home security control panel. Module 3, Raspberry Pi Robotics Essentials, starts with configuring and programming Raspberry Pi, along with construction of biped platform. It further covers in-depth planning of biped with the details of connecting webcam, hardware and software in order to use input visual data into our system. [ i ] Preface What you need for this learning path • Module 1, Raspberry Pi By Example, recommends you to use the following kit: Raspberry Pi Model B, B+ or 2 (Multiple boards for last two chapters) USB hub, powered preferably Networking hub PC for preparing SD card Webcam and/or Pi Camera • Module 2, Building a Home Security System with Raspberry Pi,, will need the following software: Gparted dd fake-hwclock Win32 Disk Imager 0.9.5 PuTTY i2c-tools • Module 3, Raspberry Pi Robotics Essentials, asks you to use Raspbian, putty, Image Writer for Windows, libusb-1.0-0-dev and VncServer. Who this learning path is for Novice programmers and hobbyists who want to understand how to use Raspberry Pi to build interesting projects and home automation systems, as well as for those who want to delve deeper into the world of Raspberry Pi Reader feedback Feedback from our readers is always welcome. Let us know what you think about this course—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the course's title in 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 at www.packtpub.com/authors. [ ii ] Preface Customer support Now that you are the proud owner of a Packt course, 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 this course from your account at http://www.packtpub.com. If you purchased this course elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you. You can download the code files by following these steps: 1. Log in or register to our website using your e-mail address and password. 2. Hover the mouse pointer on the SUPPORT tab at the top. 3. Click on Code Downloads & Errata. 4. Enter the name of the course in the Search box. 5. Select the course for which you're looking to download the code files. 6. Choose from the drop-down menu where you purchased this course from. 7. Click on Code Download. You can also download the code files by clicking on the Code Files button on the course's webpage at the Packt Publishing website. This page can be accessed by entering the course's name in the Search box. Please note that you need to be logged in to your Packt account. Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of: • WinRAR / 7-Zip for Windows • Zipeg / iZip / UnRarX for Mac • 7-Zip / PeaZip for Linux The code bundle for the course is also hosted on GitHub at https://github.com/ PacktPublishing/Raspberry-Pi-Making-Amazing-Projects-Right-from- Scratch- [ iii ] Preface 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 courses—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 course. If you find any errata, please report them by visiting http://www. packtpub.com/submit-errata, selecting your course, 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 course in the search field. The required information will appear under the Errata section. Piracy Piracy of copyrighted 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 [email protected] 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 If you have a problem with any aspect of this course, you can contact us at [email protected], and we will do our best to address the problem. [ iv ] Course Module 1: Raspberry Pi By Example Chapter 1: Introduction to Raspberry Pi and Python 3 Single-board computers 3 Raspberry Pi 5 Operating systems 9 Setting up the Raspberry Pi 10 Getting started with Python 21 Summary 30 Chapter 2: Minecraft Pi 31 Introduction to Minecraft Pi 31 Playing Minecraft Pi 32 Python programming for Minecraft Pi 40 Summary 46 Chapter 3: Building Games with PyGame 47 Introducing PyGame 47 Installing PyGame 48 Drawing a binary fractal tree 49 Building a snake game 53 Summary 60 Chapter 4: Working with a Webcam and Pi Camera 61 Working with webcams 61 Working with the Pi Camera and NoIR Camera modules 68 Summary 74 [ i ] Table of Contents Chapter 5: Introduction to GPIO Programming 75 Introducing GPIO pins 76 Building an LED Blinker 78 Installing PiGlow 82 Using PiGlow 85 Building a binary clock 87 Summary 91 Chapter 6: Creating Animated Movies with Raspberry Pi 93 Introducing stop-motion animation 93 Setting up the prerequisites 94 Rendering the video 100 Summary 101 Chapter 7: Introduction to Computer Vision 103 Introducing Computer Vision 104 Introducing OpenCV 104 Setting up Pi for Computer Vision 105 Introducing NumPy 108 Working with images 111 Working with Webcam using OpenCV 116 Retrieving image properties 119 Arithmetic operations on images 120 Splitting and merging image color channels 124 Logical operations on images 126 Colorspaces and conversions 128 Tracking in real time based on color 131 Summary 132 Chapter 8: Creating Your Own Motion Detection and Tracking System 133 Thresholding images 133 Noise 138 Morphological transformations on images 143 Motion detection and tracking 144 Summary 148 Chapter 9: Grove Sensors and the Raspberry Pi 149 Introducing the GrovePi 149 Setting up the GrovePi 151 Displaying the weather 156 Intruder detection system 159 Summary 161 [ ii ] Table of Contents Chapter 10: Internet of Things with the Raspberry Pi 163 Introducing the Internet of Things 164 Installing the Twitter API for Python 164 Setting up a SQLite database in Python 170 Building a tweeting weather station 174 Summary 180 Chapter 11: Build Your Own Supercomputer with Raspberry Pi 181 Introducing a Pi-based supercomputer 182 Installing and configuring MPICH2 and MPI4PY 182 Setting up the Raspberry Pi cluster 190 Setting up SSH access from the host to the client 193 Running code in parallel 195 Performance benchmarking of the cluster 196 Introducing N-Body simulations 196 Installing and running GalaxSee 198 Summary 201 Chapter 12: Advanced Networking with Raspberry Pi 203 Introducing DHCP 203 A few networking concepts 204 Configuring a Raspberry Pi to act as a DHCP server 206 Introducing Domain Naming System (DNS) 210 Setting up a DNS server on the Pi 211 Configuring the setup for a web server 213 Automating node discovery in a network 215 Summary 217 Chapter 13: Setting Up a Web Server on the Raspberry Pi 219 Introducing and installing Apache on Raspbian 220 Installing PHP and MySQL 222 Installing WordPress 223 Summary 231 Chapter 14: Network Programming in Python with the Pi 233 The basics of sockets 233 The difference between TCP and UDP 234 Looking back 254 A Telnet client in Python 254 A chat program 256 References 261 Exercise 262 Summary 262 [ iii ] Table of Contents Chapter 15: Newer Raspberry Pi Models 263 The Raspberry Pi Zero 263 The Raspberry Pi 3 268 Course Module 2: Building a Home Security System with Raspberry Pi Chapter 1: Setting Up Your Raspberry Pi 273 Which flavor of Pi? 273 Preparing the SD card 278 Setting up your Pi 284 Summary 290 Chapter 2: Connecting Things to Your Pi with GPIO 291 Prerequisites 291 Say hello to the GPIO 292 Getting acquainted with the GPIO 296 The most elaborate light switch in the world 303 Summary 305 Chapter 3: Extending Your Pi to Connect More Things 307 Prerequisites 307 The I2C bus 308 Give me power 310 Building an I2C expander 312 Using ready-made expansion boards 317 Summary 319 Chapter 4: Adding a Magnetic Contact Sensor 321 Prerequisites 321 The working of magnetic contact sensors 322 Setting up the I2C port expander 324 Connecting our magnetic contact sensor 329 Monitoring the sensor 331 Anti-tamper circuits 332 Getting into the zone 334 Summary 336 [ iv ]

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.