Book Image

Learning IoT with Particle Photon and Electron

By : Rashid Khan, Kajari Ghoshdastidar, Ajith Vasudevan
Book Image

Learning IoT with Particle Photon and Electron

By: Rashid Khan, Kajari Ghoshdastidar, Ajith Vasudevan

Overview of this book

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.
Table of Contents (11 chapters)

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 6Hacking 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.