Learning IoT with Particle Photon and Electron - Rashid Khan - E-Book

Learning IoT with Particle Photon and Electron E-Book

Rashid Khan

0,0
25,19 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

Develop applications on one of the most popular platforms for IoT using Particle Photon and Electron with this fast-paced guide

About This Book

  • Get an introduction to IoT architecture, command-line build tools and applications of IoT devices and sensors
  • Design and develop connected IoT applications using Particle Photon and Electron in a step-by-step manner, gaining an entry point into the field of IoT
  • Get tips on troubleshooting IoT applications

Who This Book Is For

This book is for developers, IoT enthusiasts and hobbyists who want to enhance their knowledge of IoT machine-to-machine architecture using Particle Photon and Electron, and implement cloud-based IoT projects.

What You Will Learn

  • Setup the Particle Photon and Electron on the cloud using the command-line tools
  • Build and deploy applications on the Photon and Electron using the Web-based IDE
  • Setup a local cloud server to interact with Particle Photon and Electron
  • Connect various components and sensors to Particle Photon and Electron
  • Tinker with the existing firmware and deploy a custom firmware on the Photon and Electron
  • Setup communication between two or more Particle Photon and Electron
  • Debug and troubleshoot Particle Photon and Electron projects
  • Use webhooks to communicate with various third-party server applications

In Detail

IoT is basically the network of physical devices, vehicles, buildings and other items—embedded with electronics, software, sensors, actuators, and network connectivity that enable these objects to collect and exchange data.. The number of connected devices is growing rapidly and will continue to do so over years to come. By 2020, there will be more than 20 billion connected devices and the ability to program such devices will be in high demand. Particle provides prototyping boards for IoT that are easy to program and deploy. Most importantly, the boards provided by Particle can be connected to the Internet very easily as they include Wi-Fi or a GSM module.

Starting with the basics of programming Particle Photon and Electron, this book will take you through setting up your local servers and running custom firmware, to using the Photon and Electron to program autonomous cars. This book also covers in brief a basic architecture and design of IoT applications. It gives you an overview of the IoT stack. You will also get information on how to debug and troubleshoot Particle Photon and Electron and set up your own debugging framework for any IoT board. Finally, you'll tinker with the firmware of the Photon and Electron by modifying the existing firmware and deploying them to your boards.

By the end of this book, you should have a fairly good understanding of the IoT ecosystem and you should be able to build standalone projects using your own local server or the Particle Cloud Server.

Style and approach

This project-based guide contains easy-to-follow steps to program Particle Photon and Electron. You will learn to build connected applications with the help of projects of increasing complexity, and with each project, a new concept in IoT is taught.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 152

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Learning IoT with Particle Photon and Electron
Credits
About the Authors
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the color images of this book
Errata
Piracy
Questions
1. Introducing IoT with Particle Photon and Electron
Evolution of the IoT
Why the IoT has become a household word now
Hardware and software in the IoT ecosystem
Essential terminology
Network protocols
Market survey of IoT development boards and cloud services
IoT development boards
Cloud services (PaaS, BaaS, M2M)
What is Particle?
The journey of Particle
Why Particle?
What does Particle offer?
Photon, Electron, and Core
Spark Core
Particle Photon
Particle Electron
Comparison
Summary
2. Fire Up Your Kit
Essentials of FreeRTOS and hardware resources
Flow diagram for the Twitter project
Getting the Photon online
Setting up the Photon or Core
Software and hardware requirements
Software setup
Connecting Particle Photon or Core
The Web IDE
Twitter and e-mail interaction project
Setting up a Twitter developer account
Sending web requests using Particle webhooks
Creating a webhook
Listing and deleting webhooks
Putting it all together
Setting up the Twitter and e-mail webhook
How to sense motion?
Sensing button presses - programming the buttons
Tweets and e-mail
Troubleshooting
Summary
3. P2P and Local Server
Client-server versus P2P networks
Traditional client-server architecture
Peer-to-peer network architecture
Client-server versus P2P 
Advantages and disadvantages of P2P networking
Setting up a P2P network for Particle devices
Flash the VoodooSpark firmware
Connect the Particle board with VoodooSpark
Controlling your Particle board using the keyboard
Local server setup
Advantages and disadvantages of Particle local server
Installing Particle server on a local machine
Configuring the local server
Alternate protocols for IoT
MQTT
CoAP
Summary
4. Connecting the Sensors
Overview of the project
Hardware components and setup
RFID reader module RC522-RFID and RFID tags
PIR motion sensor
Data flow diagrams
Communication between the Photons
Sample code
Photon with the RFID reader
Photon with the motion sensor
Data storage on the cloud
Cloud data analysis and SMS notification
Troubleshooting
Summary
5. Of Cars and Controllers
Building the model car - hardware components
Wheels
L293D motor driver
65 RPM DC Right Angled motor
Chassis
Power supply and Li-Po battery
Breadboard and jumper wires
Building the model car - prerequisites
Putting it all together and controlling the car
The code
Running the program and controlling the car
Moving the car with gestures
How it works
The code
Programming the car with the Electron
Putting it all together (again)
The code
Troubleshooting
Summary
6. Hacking the Firmware
What is firmware?
A bit of history
Obtaining and flashing firmware
Obtaining firmware
Obtaining firmware by direct download
Obtaining firmware by building from source
ARM GCC
Make
Git
Getting the firmware source code
Compiling the code
Burning firmware onto the device
Burning firmware using the OTA method
Burning firmware using Particle-CLI
Burning firmware using the DFU-Util method
Installing DFU-Util
Flashing firmware
Custom firmware
Summary

Learning IoT with Particle Photon and Electron

Learning IoT with Particle Photon and Electron

Copyright © 2016 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 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 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: 1070916

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham 

B3 2PB, UK.

ISBN 978-1-78588-529-7

www.packtpub.com

Credits

Authors

Rashid Khan

Kajari Ghoshdastidar

Ajith Vasudevan

Project Coordinator

Suzanne Coutinho

Commissioning Editor

Neil Alexander

Proofreader

Safis Editing

Acquisition Editors

Aaron Lazar

Reshma Raman

Indexer

Rekha Nair

Content Development Editor

Pooja Mhapsekar

Graphics

Jason Monteiro

Technical Editor

Sunith Shetty

Production Coordinator

Aparna Bhagat

Copy Editor

Sonia Mathur

About the Authors

Rashid Khan is a programmer living in Bangalore. He is one of the founders of Yellow Messenger, a company that specializes in building bots for commerce. Prior to founding Yellow Messenger, he worked at EdgeVerve Systems, where he built backend systems to support IoT devices. He is an open source enthusiast and loves to experiment with new technologies. He is involved with a number of open source organizations, such as GNOME, Mono, Tomboy Notes, and Banshee and has built a Django (Python) library for Apache Spark called Django-LibSpark.

His interests lie in the field of Artificial Intelligence and interfacing software with real-world objects. Apart from programming, he loves to cycle and play tennis.

I am really thankful to my mother and father for providing the motivation and guidance to help me push myself constantly. My co-founders at Yellow Messenger, Anik, Raghu, and Kishore, provided constant support to experiment with new ideas for this book, and I would like to extend my gratitude for that. I would like to thank Rajeshwari Ganesan, my manager at EdgeVerve Systems, for giving me the opportunity to author this book. I would like to extend my gratitude to Ajith and Kajari, my coauthors, without whom this book would not be possible. This book would be incomplete without the guidance and mentorship of my friends and co-workers at EdgeVerve. I am extremely thankful to Chetan, who helped a lot with the sensors and data, and Nelly (Jeonghyun Kang), who helped with the firmware and testing out the initial projects.

Kajari Ghoshdastidar got her PhD in wireless sensor networks in 2009 and has been active in IoT-related hobby project work since then. She has worked in the software industry for the last 6 years as a technology architect, software developer, and a computer scientist. She is a technology geek, takes part in hackathons, and is always exploring new technologies and electronic gadgets.

She is currently part of the systems engineering team at EdgeVerve, working as a computer scientist.

First of all, I would like to thank Rajeshwari Ganesan, my mentor and manager at Edgeverve, for inspiring me to pen this book and closely guiding me all the way, and Rashid and Ajith for being the most awesome coauthors I could wish for. This book wouldn’t be complete without the support of my colleagues at Edgeverve, Chetan Kumar Velumurugan, who helped us a lot with his deep knowledge of sensors and accessories, and Nelly (Jeonghyun Kang), who helped with setting up and testing out the initial projects.

Ajith Vasudevan is an electronics, computer, and IoT enthusiast who likes to apply his knowledge in these fields to make modern living easy for himself and others around him. He has a bachelor's of technology degree in electrical and electronics engineering. He was interested in automation and IoT even before the term IoT became commonplace. He designed and built an automatic overhead-tank motor operator using $1 worth of electronic parts back in 1995, which is operating at his parent’s home to this day. He has automated and made it simple and efficient to operate many household appliances, for example, an automatic geyser switch that turns itself off after 10 minutes, saving electricity. It can be set to switch on at any specified time or can be controlled from anywhere. Today, even his friends and neighbors use this system.

Ajith has worked in the heavy electrical industry before joining his current employer, Infosys Technologies Limited, in the year 2000. He is presently a senior computer scientist at EdgeVerve Systems, a subsidiary of Infosys. At work, he enjoys programming and has done so for over a decade and a half.

I would like to thank Rajeshwari Ganesan for introducing me to the coauthors and Packt Publishing and for giving me the opportunity to coauthor this book. It has been an enjoyable and great learning experience for me.

www.PacktPub.com

eBooks, discount offers, and more

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 [email protected] 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.

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 PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

Preface

Devices made by Particle (the IoT company formerly known as Spark) are one of the most popular IoT platforms for hobbyists and professionals alike. This fast-paced guide will help you develop IoT-based applications using two of Particle's popular boards—the Photon and the Electron.

What this book covers

Chapter 1, Introducing IoT with Particle Photon and Electron, introduces you to IoT and common hardware and software used in building IoT projects, and lists popular IoT boards. The chapter then introduces Particle, the IoT company, and describes its three main products—the Photon, the Electron, and the Core.

Chapter 2, Fire Up Your Kit, gives a brief introduction to the workings of FreeRTOS, the operating system of Photon. The chapter goes on to help you build a Twitter and email-interaction project. You will learn to code for Photon using ParticleJS in the web-based IDE called Particle Build.

Chapter 3, P2P and Local Server, compares two popular network architectures used in IoT projects and shows you how to set up a P2P network for Particle devices. This chapter also describes how to set up a local server to make communication between devices faster. Finally, we will introduce you to other popular protocols and architectures used in IoT.

Chapter 4, Connecting the Sensors, shows you how to build a smart kitchen using a network of Photons with cloud-based data storage, analysis, and notifications using webhooks.

Chapter 5, Of Cars and Controllers, teaches you how to use Photon and Electron to build a connected model car that is capable of being controlled remotely using a keyboard. We will also show you how to modify this project to control the car by hand gestures using a Leap Motion controller.

Chapter 6, Hacking the Firmware, talks about the role of firmware in the Particle devices and shows you different ways to obtain and deploy the firmware on them. We will also list the advantages of custom firmware, taking the case of the VoodooSpark custom firmware as an example.

What you need for this book

This book describes various IoT projects that you will want to try out. In order to successfully execute these projects, the following software needs to be installed on your computer:

Linux (preferable) or the Windows operating system.eBook reader helps you open the eBook version of this book on your computer for ease of copying code snippets to and from the book to your code editor on the computer.A text editor, such as GEdit (Linux) or Notepad++ (Windows), to edit the code locally.A web browser to access and use a web-based code editor and to download software.Node.js (https://www.nodejs.org)—a JavaScript runtime built on Chrome's V8 JavaScript engine.Particle CLI (https://docs.particle.io/guide/tools-and-features/cli/photon/)—a command-line interface from Particle.Particle driver for Windows is required only if you're using Windows OS. For more information, see https://docs.particle.io/guide/getting-started/connect/photon/, and look for the Installing the Particle driver section.Cylon.js (https://cylonjs.com/)—a JavaScript framework for robotics, physical computing, and IoT.ARM GCC—an ARM variant of the GCC compiler tool chain for the C language.make, a command-line utility that compiles and builds binaries from source code.Git, a distributed version-control system.

The Obtaining firmware by building from source section of Chapter 6, Hacking the Firmware, describes how you can obtain ARM GCC, make, and Git for Windows, Linux, and Mac OS.

DFU-Util (http://dfu-Util.sourceforge.net/)—a utility to download and upload firmware to/from devices connected over USB.

The Burning firmware using the DFU-Util method section of Chapter 6, Hacking the Firmware, describes how you can obtain DFU-Util for Windows, Linux, and Mac OS.

Who this book is for

This book is for developers, IoT enthusiasts, and hobbyists who want to enhance their knowledge of IoT machine-to-machine architecture using Particle Photon and Electron and implement cloud-based IoT projects.

Conventions

In this book, you will find a number of text styles 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: "The driver is called spark_core.cat."

A block of code is set as follows:

{ "event": "twitterFetch", "url": "https://api.twitter.com/1.1/search/tweets.json", "requestType": "GET", "headers": { "Authorization" : "Bearer XXXXXX" },

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

$ particle setup

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Select the Advanced tab."

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 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 book'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.

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 color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/LearningIoTwithParticlePhotonandElectron_ColorImages.pdf.

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 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 book, you can contact us at [email protected], and we will do our best to address the problem.

Chapter 1. Introducing IoT with Particle Photon and Electron

The Wikipedia page on the Internet of Things (IoT) says the following:

"The Internet of Things (IoT, sometimes Internet of Everything) is the network of physical objects or "things" embedded with electronics, software, sensors, and connectivity to enable objects to exchange data with the manufacturer, operator and/or other connected devices based on the infrastructure of International Telecommunication Union's Global Standards Initiative."

This chapter starts with a brief walkthrough of the evolution of the IoT followed by an overview of the basics of IoT-related software and hardware, which every IoT enthusiast should know. The discussion then moves on to introduce Particle, an IoT company (https://www.particle.io/), followed by a description of Particle's popular IoT products—Core, Photon, and Electron.

This chapter is divided into the following sections:

Evolution of the IoTHardware and software in the IoT ecosystemMarket survey of IoT development boards and cloud servicesWhat is Particle?Photon, Electron, and Core

Evolution of the IoT

It is not very clear exactly who coined the term IoT. Kevin Ashton (https://en.wikipedia.org/wiki/Kevin_Ashton) supposedly coined the phrase Internet of Things while working for Procter & Gamble (P&G) in 1999. Kevin was then working on an RFID (https://en.wikipedia.org/wiki/Radio-frequency_identification) initiative by P&G, and proposed taking the system online to the Internet.

In 2005, UN's International Telecommunications Union (ITU) (http://www.itu.int/), published its first report on IoT. In 2008, the global non-profit organization IPSO Alliance (http://www.ipso-alliance.org/