Get Started Free
Back to the blog

Using AWS Greengrass to Enable IoT Edge Computing

Picture of John Vanderzyden (Guest Author)
byJohn Vanderzyden (Guest Author)

Serverless computing continues to grow in popularity—and practical use. AWS Lambda is the flagship service among all of the various offerings. AWS continues to add highly useful features and various integrations, and this continues to encourage more serverless technology adoption. Many of the new features add significant value in operations, security, and ease-of-deployment.

Using AWS Greengrass to Enable IoT Edge Computing

Previously, Lambda functions would only run in the AWS cloud. But now, AWS users can employ Lambda@Edge to run Lambda functions on Cloudfront edge locations, and IoT devices can execute Lambda functions locally with Greengrass. Effectively, this means that Lambda can run on virtually anything—a smartphone or television, server, monitoring devices, or even a Tesla! Greengrass is becoming the dominant force in edge computing.

AWS Greengrass: How it Works

AWS Greengrass takes AWS Lambda and AWS IoT functionality and makes it available for local deployment and execution on field devices that may have intermittent network connections—yet use the very same programming constructs that run in the AWS public cloud. With AWS Greengrass, you can build solutions that connect various IoT devices to the cloud—and also connect each of these devices with one another. Any device that supports x86 or ARM chip architecture and runs Linux can host the Greengrass Core. With this core, the device functions as a hub that provides communication among devices that run the AWS IoT Device SDK.

After defining a Greengrass Group, consisting of devices that have run the AWS IoT Device SDK, you configure the group so that the devices communicate with each another. When Internet connectivity is available, Greengrass will synchronize all data with all devices in the group.

AWS Greengrass Group

Previously, AWS IoT devices didn’t have a standard message queue for temporary storage in the event of Internet outage. Now, it’s easy to configure a device that runs the Greengrass Core to function as a local hub for other devices in its group. All devices in the group will eventually synchronize and maintain discovery, securely communicate, process, and store device data. In cases of intermittent Internet connectivity, this is done by means of a local network—on local CPU and storage.

After Internet connectivity resumes, messages that persist in the local queue(s) are sent to AWS cloud for durable storage and analytics. Lambda functions are event driven, so they are deployable on to any device hub and available for processing events that originate with other devices in the group. Greengrass Core-enabled devices can also be setup to track the state of other field devices by means of device shadowing, so that hub can be aware of the state of any particular device (if the device resets or restarts).

Sample Greengrass Applications

AWS provides a sample application that demonstrates how Greengrass is used in a miniature fulfillment center. Qualcomm showcases another practicable application, in which they pair their Snapdragon processor with AWS Greengrass. This design is useful in managing both local-device and cloud-based storage, along with messaging for critical IoT applications that typically cannot rely on a continuous cloud connection—as is the case in contexts such as facility automation, medical equipment, and industrial machinery.

Edge Processing in the Industrial Internet of Things

In many IoT architectures, sensors collect data in real-time at frequent intervals (perhaps many times per second). For mining, vehicular operations, and manufacturing, such sensors might measure vibration, detect types of noise, or monitor for water or gas leaks. Precision agriculture employs sensors that constantly record wind velocity, temperature, humidity, and soil moisture values.

The Intelligent Solutions Group at John Deere uses AWS IoT for precision agriculture to maximize scarce natural resources to feed more people, more efficiently. The core of precision agriculture is the extensive automation that is built into a wide array of farming equipment. The guidance for these machines is done with GPS technology and specialized software. Farmers can very precisely control seed placement and chemical applications. Sensors and IoT device management with technologies such as AWS Greengrass makes such advances possible.

Conventionally, many of the scenarios given above involve sensors that take many readings per minute, accumulate a large set of mostly useless data that contains some valuable data points. Much of the time, the sensors detect no change and report the same readings inside a normal range. Infrequently, data may indicate that excessive vibration, water leakage, dry soil, or equipment malfunction.

By contrast, edge processing provides for messaging pathways by which sensors send readings to a hardware gateway. That gateway functions as a hub for a collection (Greengrass group) of sensors, and the logic for that hub can determine if any particular piece of data is actionable.

Quick Start with Greengrass

AWS Greengrass setup begins with the creation of a Greengrass group. Setting up an AWS Greengrass core device involves preparing the hardware, downloading the core software, and installing it. After configuring your AWS Greengrass core, you add IoT devices to your Greengrass group.

Create a Greengrass group

The Greengrass Group is a cloud-configured managed collection of local devices and Lambda functions that are programmable to communicate with each other through a Core device. Groups may contain as many as 200 local devices.

Easy creation of a group: To speed up and simplify group creation, AWS can perform much of the setup for you and use default settings. If you don’t opt for this easy setup, then you’ll need to perform each of these steps manually:

  • Create a new Greengrass Group in the AWS cloud
  • Provision a new Core in the IoT Registry and add it to the Group
  • Generate both a public and private key set for your Core
  • Using the keys, generate a new security certificate for the Core
  • Attach a default security policy to the certificate

Download and store your Core’s security resources

During initial setup, you can wait to connect your device. But, you must download your certificate, public key, and private key and then secure them. They won’t be available for download in the future.

Core software

Of course, you’ll need to download the current Greengrass Core software package, which will include the following:

  • Greengrass daemon
  • License information
  • Version release notes

Final steps

Lastly, you’ll need to:

  • Load the Greengrass software onto your devices
  • Connect the devices to AWS, making each an AWS IoT device
  • Add these AWS IoT devices to your Greengrass group

There is plenty of information available to help you learn this technology. AWS provides extensive Greengrass tutorial and reference documentation.

Testing and releasing a Greengrass app

As with any other software, it’s essential to think about the testing and release process for the applications that will run on the field devices. Conveniently, the Greengrass Core functions are also Lambda functions—which are easily testable in AWS. To automate the testing and release process for your Greengrass Core code changes, you can build continuous integration and delivery (CI/CD) pipelines that use common AWS elements.

Code that is already stored and managed in AWS CodeCommit or Github is the best starting point for a pipeline. Arrange the AWS CodePipeline steps to take code from Git, then build it with AWS CodeBuild together with some unit tests. Then, run functional and integration tests prior to deployment out to the field devices.

For integration and comprehensive system testing of your IoT applications, prepare a AWS test environment for the cloud components, and deploy Greengrass functions to AWS for testing. Bring the edge devices and sensors into the testing mix by building a simulation of field devices that send data back from your Greengrass Core to the AWS ecosystem.

Once all tests are successful and complete, deploy the code changes with AWS CodeDeploy—the last step in the CodePipeline. With CodeDeploy, you distribute changes to a large variety of target devices and choose from among several deployment approaches.

Greengrass is a useful new service that AWS launched to extend public cloud compute to the edge. Let’s see what interesting use cases come out of this…

Back to the blog