AWS IoT Greengrass software is readily available on PHYTEC's phyBOARD-Zeta to enable cloud capabilities. Greengrass allows data to be collected, analyzed, and acted upon at the source, while using the cloud for storage, analytics, and securely connecting to other devices. Code can be deployed to individual SOMs or to device fleets through the cloud in AWS Lambda functions via Greengrass, facilitating the process of remote software updates and certificate rotation. This quick-start will demonstrate how to deploy a simple "Hello World" Lambda function to the phyBOARD-Zeta and view the results in the AWS IoT Console.
This tutorial is based off of "Getting Started with AWS IoT Greengrass" in the AWS IoT Greengrass Developer Guide, which can be found here: https://docs.aws.amazon.com/greengrass/latest/developerguide/gg-gs.html.
|1||Create or log into your AWS account. Here is the current link to the console sign-in: https://portal.aws.amazon.com/billing/signup#/start|
Connect the phyBoard-Zeta to the Internet. If this is the first time booting the board you will need to bring up the ethernet interfaces:
Run the following commands to make sure everything is correctly configured for Greengrass:
If there are missing dependencies beyond Node v6.10 and Java 8, then the Greengrass option was not correctly configured in the image build. Try rebuilding the image and then proceed to the next step when all of the required dependencies are configured and installed.
Create a Greengrass group.
|6||Name your group in the "Group Name" box and click "Next".|
|7||Use the name provided for the core, and click "Next".|
|8||Click "Create Group and Core" to finalize creating the Greengrass Group (AWS-side resources for the your set of devices).|
|9||On the confirmation page, download the certificate package. No need to download the software configuration package. Click "Finish".|
|10||Transfer the certificate package from your computer to the i.MX7.|
See this link for more details regarding the transfer of files: Copying Files to the Device
|11||Return to the i.MX7. Decompress the certificate file and copy the root CA to the device. Check that the root.ca.pem isn't empty.|
|12||Start AWS GG daemon on the i.MX7 and check that the daemon is running (there will be a root entry for /greengrass/ggc/packages/1.7.0/bin/daemon).|
|13||Create the "Hello World" Lambda function. Return to the AWS IoT Core Console and select "Software"|
Download the SDK:
|15||Decompress the "greengrass-core-python-sdk-1.3.0.tar.gz" downloaded from the last step.|
Windows: install 7-Zip, right click on file, and choose "7-Zip" → "Open archive" → drag folder to desired location (image shows contents of folder)
macOS: double click the file, open "sdk", and then unzip python_sdk_1_3_0.zip
Unix: use the command line:
|16||Now actually create the Lambda function. Move the greengrasssdk folder into the "examples"→ "HelloWorld" folder and zip them together.|
Unix (including macOS):
|17||Package the Lambda. On the group page in the AWS IoT Console, select "Lambda" → "Add Lambda" → "Create new Lambda".|
|18||In the AWS Lambda Console, fill out the "Author from Scratch" box like in the following screenshot, and then select "Create function" on the bottom:|
Publish the Lambda function:
Create an alias/ nickname for the Lambda function:
Add the Lambda to your GG group to deploy:
Edit the Lambda's configuration for the group:
Create a subscription to the MQTT topic:
Deploy the Lambda:
See the MQTT messages:
There should now be a "Hello world!" MQTT message appearing in the AWS IoT test console every five or so seconds!