Agus Kurniawan Smart Internet ofThings Projects Dise uVeVhow to build your own smart Internet of Things pröjeets and bring a new degree of interconnectivity to your world Smart Internetof Things P Cts Discover how to build your own smart Internet of Things projects and bring a new degree of interconnectivity to your world Agus Kurniawan Pacl BIRMINGHAM - MUMBAI Smart Internetof Things Projects Copyright@ 2016 Packt Publishing All rights reserved No part of this book may be reproduced, stored in a retrieval svstem,or transmitted in any form or by any means, without the prior written permissionof the publisher, except in the case of brief quotations embedded in critical articles or reviews Everyefforthas 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: September 2016 Production reference: 1280916 Published by Packt Publishing Ltd Livery Place 35 Livery Street Birmingham 1332PB, UK ISBN 978-1-78646-651-8 www.packtpub com Credits Author Agus Kurniawan Project Coordinator Reviewer Proofreader Safis Editing Phodal Huang Acquisition Editor Rahul Nair Kinjal Bari Indexer Pratik Shirodkar Content Development Editor Trusha Shriyan Graphics Kirk DPenha Technical Editor Production Coordinator Nirant Carvalho Copy Editor Safis Editing Shantanu N Zagade Cover Work Shantanu N Zagade Table of Contents Preface Chapter 1: Making Your IOT Project Smart Introducing basic statistics and data science Python for computational statistics and data science Python libraries for computational statistics and data science Scikit-learn Shogun 7 7 Statsmodels 8 NumPy Pandas sciPy SymPy Building a simple program for statistics IOT devices and platforms Arduino Raspberry Pi BeagleBone Black and Green 10T boards based on ESP8266 MCU? IOT boards-based Tl CC3200 MCU Sensing and actuating on 10Tdevices Sensing and actuating on Arduino devices Sensing and actuating on Raspberry Pi devices Setting up Accessing RaspberryPi GPIO Sensing through sensor devices 10 10 13 15 17 19 21 22 31 31 32 36 Tahlf Ci"ttrnts Building a smart temperature controller for your room Introducing PID controller in Python ImplementingPID controller using PID controller Controllingroom temperature Summary References for IOT Pro•ects Cha ter 2: Decision S stem machine learning Introductionto decision system and Decisionsystem-based Bayesian Decisionsystem-basedfuzzy logic Python libraries for building a decision system Bayesian Fuzzy logic Building a simple decision system-based Bayesian theory Integratinga decision system and IOT project Building your own decision system-based 10T Wiring Writing the Python program Testing Enhancement Summary References Chapter 3: Building Your Own Machine Vision Introducing machine vision Introducing the OpenCV library Deploying OpenCV on Raspberry Pi Building a simple program with OpenCV Working with camera modules Camera modules based on the CSI interface Camera modulesbased on USB interface Camera modules-based serial interface Camera modules with multi-interfaces Accessing camera modules from the OpenCV library Introducingpatternrecognition for machine vision Buildinga trackingvision system for moving objects Building your own IOT machine vision Deploying Pixy CMUcam5 on Raspberry Pi Assembly Updating the Pixy CMUcam5 firmware 39 39 40 48 53 53 55 55 56 57 59 59 65 68 71 73 74 75 80 81 81 81 83 83 84 85 90 93 94 96 97 97 99 103 105 105 106 106 Table of Contents Testing 107 Loading streaming video Tracking an object Tracking an object with a Pan[Tilt module Running the Python application Clearing all signatures Summary References 107 109 112 113 113 114 114 Chapter 4: Making Your Own Autonomous Car Robot Introducing autonomous systems Introducing mobile robots Building your own car robot 115 115 117 118 119 121 DIY robot platforms Assembled robot platform Working with the Pololu Zumo robot for Arduino 124 Controlling a car robot from a computer 130 Working with a GPS module for navigation 139 Introducing map engine platforms 146 Building a car-basedGPS 151 How we get it to work? How we get it to work? How we get this to work? 129 137 145 149 How we get it to work? Making your own autonomous car Summary References 154 156 156 Chapter 5: Building Voice Technology on IOT Projects Introduce a speech technology Introduce sound sensors and actuators Introduce pattern recognition for speech technology Reviewing speech and sound modules for IOT devices Build your own voice commands for IOT projects Setting up EasyVR shield Building voice commands Wring your voice command board Writing sketch program Testing Make your 10T board speak Setting up Wring Writing sketch program Testing t iii I 157 157 158 168 169 171 172 174 178 178 183 184 184 184 185 186 Tablco Contents MakeRaspberry Pi speak 186 Writing Python program Wnat's next? 190 191 Setting up Summary References Cloud for IOT Pro•ects Cha ter 6: Buildin Data Science-based Introduce cloud technology Introducing cloud-based data science Connecting IOT boards to cloud-based server Microsoft Azure IOT Amazon AWS IOT Arduino Cloud Setting up Arduino Cloud Wiring for demo Adding Arduino Cloud library Updating Arduino Cloud web SSL certificate Writing program for Arduino Cloud Working with Microsoft Azure IOT Hub Setting up Microsoft Azure IOT Hub Registering IOT device Writing program Building data science-based cloud Deploying Azure Machine learning Publishing Azure ML as web service Make 10T application with data science-based cloud Summary Index 191 191 193 193 195 195 196 197 198 198 202 203 204 207 212 212 215 220 228 229 230 232 233 235 .. .Smart Internetof Things P Cts Discover how to build your own smart Internet of Things projects and bring a new degree of interconnectivity to your world Agus... world Agus Kurniawan Pacl BIRMINGHAM - MUMBAI Smart Internetof Things Projects Copyright@ 2016 Packt Publishing All rights reserved No part of this book may be reproduced, stored in a retrieval... permissionof the publisher, except in the case of brief quotations embedded in critical articles or reviews Everyefforthas been made in the preparation of this book to ensure the accuracy of the