Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning AWS IoT

You're reading from  Learning AWS IoT

Product type Book
Published in Jan 2018
Publisher Packt
ISBN-13 9781788396110
Pages 278 pages
Edition 1st Edition
Languages
Author (1):
Agus Kurniawan Agus Kurniawan
Profile icon Agus Kurniawan

Table of Contents (14) Chapters

Title Page
Packt Upsell
Contributors
Preface
Getting Started with AWS IoT Connecting IoT Devices to AWS IoT Platform Optimizing IoT Computing Using AWS Greengrass Building Local AWS Lambda with AWS Greengrass Expanding IoT Capabilities with AWS IoT Button Visualizing AWS IoT Data Building Predictive Analytics for AWS IoT Securing AWS IoT Other Books You May Enjoy Index

Chapter 3. Optimizing IoT Computing Using AWS Greengrass

Some companies probably have security policies that do not allow some internal devices, such as computers and IoT devices, to connect to the internet directly. To solve these issues, they provide proxy or bridge servers to accommodate connectivity between internet devices and internet networks. For IoT cases, we can build a gateway server to serve those requests. In this chapter, we will learn how IoT devices connect to AWS and perform computation locally. We will explore and implement AWS Greengrass to serve all IoT devices to perform AWS computations. We will deploy AWS Greengrass and use Raspberry Pi 3 as AWS Greengrass Core.

The following is a list of topics that we will cover in this chapter:

  • Introducing AWS Greengrass
  • Exploring supported IoT devices for AWS Greengrass
  • Deploying AWS Greengrass on Raspberry Pi 3
  • Accessing AWS Greengrass
  • Building IoT projects with AWS Greengrass

Introducing AWS Greengrass


AWS Greengrass is one of the AWS services that enables you to build the AWS IoT server locally. This solution has an advantage, because our IoT devices should not connect to AWS IoT directly.

AWS Greengrass acts as a bridge or gateway for connected IoT devices. It offers AWS computation, such as AWS Lambda. We can deploy our own service over AWS Lambda on AWS Greengrass. AWS Greengrass can be implemented on a computer or device-based ARM CPU. All devices that are used for AWS Greengrass should be registered to AWS IoT. IoT devices have access to AWS Greengrass and AWS Greengrass needs to be configured in one group so that both the IoT devices and AWS Greengrass can communicate with each other.

A general overview of AWS Greengrass is depicted in the following figure. Each IoT device can connect to AWS Greengrass to perform computation without connecting to the AWS server. IoT devices and AWS Greengrass can only communicate within the Greengrass Group:

AWS Greengrass...

Exploring supported IoT devices for AWS Greengrass


To run AWS Greengrass on a machine, we should install AWS Greengrass Core.  This software can run on x86_64, ARMv7, and AArch64 (ARMv8) architecture platforms. It also supports Ubuntu 14.04 LTS, Jessie Kernel 4.1/4.4, and other Linux distributions based on Kernel 4.4 or later versions.

The list of supported IoT boards for AWS Greengrass can be found at https://aws.amazon.com/greengrass/faqs/. This book will use Raspberry Pi 3 for targeting AWS Greengrass.

Deploying AWS Greengrass on Raspberry Pi 3


In this section, we will deploy AWS Greengrass on Raspberry Pi 3 Model B. To implement AWS Greengrass deployment, we have the Raspberry Pi 3 board and an active AWS account. There are several steps to deploy AWS Greengrass on Raspberry Pi 3. Perform the following steps:

  1. Prepare Raspberry Pi 3
  2. Configure Raspberry Pi 3 and other IoT devices to AWS IoT
  3. Install AWS Greengrass

These steps will be explained in the following sections.

Preparing Raspberry Pi 3

The Raspberry Pi 3 board can run on several OSes. A list of supported OSes for Raspberry Pi 3 can be found at https://www.raspberrypi.org/downloads/. To work with AWS Greengrass Core, it is recommended that you install the latest Raspbian Linux OS for Raspberry Pi, which can be found at https://www.raspberrypi.org/downloads/raspbian/. For a refresher on installation on Raspberry Pi 3, I recommend you follow the instructions mentioned at https://www.raspberrypi.org/documentation/installation/installing-images...

Accessing AWS Greengrass


To access the AWS Greengrass server from IoT devices or other applications, we apply AWS SDK as usual. We only change our target server to the AWS Greengrass machine.

We need to build AWS Lambda into the AWS Greengrass Core machine. Then, we can access it from our IoT devices or computers. We will explore more about AWS Greengrass and IoT device interaction in the next chapter.  

Building IoT projects with AWS Greengrass


In this section, we will build a simple scenario to access AWS Greengrass. We will build an AWS Lambda application into AWS Greengrass. Then, we will access it from the client application. Our scenario is illustrated in the following figure:

To implement this demo, we will perform the following tasks:

  1. Prepare libraries on AWS Greengrass Core
  2. Create AWS Lambda
  3. Deploy AWS Lambda to AWS Greengrass
  4. Test

Each task will be explained in the following sections.

Preparing runtime libraries on AWS Greengrass Core

The first task to ensure our AWS Lambda runs well on AWS Greengrass Core is to prepare all requirement modules/libraries. In general, we can define three modules/libraries that should be installed on the AWS Greengrass Core machine. These modules/libraries are as follows:

  • AWS IoT SDK
  • AWS Greengrass SDK
  • External modules/libraries

AWS IoT SDK and AWS Greengrass SDK should be installed on your AWS Greengrass Core machine. You can select a runtime platform, such...

Summary


We have learned how to deploy AWS Greengrass on the Raspberry Pi 3 board and make connectivity among IoT devices. We have also built an IoT application to connect AWS Greengrass on Raspberry Pi 3.

In the next chapter, we will learn how to build AWS Lambda on AWS Greengrass and interact with IoT devices.

 

lock icon The rest of the chapter is locked
You have been reading a chapter from
Learning AWS IoT
Published in: Jan 2018 Publisher: Packt ISBN-13: 9781788396110
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}