Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


StepImage
1Create or log into your AWS account. Here is the current link to the console sign-in: https://portal.aws.amazon.com/billing/signup#/start

2

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 >>>. :

  • If using ethernet, power on the phyBOARD-Zeta, boot into Linux and log in
  • Run the listed commands to set up the Internet
    • (modify to the ethernet port that you're using)


Code Block
ifconfig eth0 up
udhcpc -i eth0


# To prevent commands from wrapping over themselves: 
shopt -s checkwinsize && resize


3

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.


Code Block
mkdir ~/Downloads && cd ~/Downloads
wget https://github.com/aws-samples/aws-greengrass-samples/raw/master/greengrass-dependency-checker-GGCv1.7.1.zip
unzip greengrass-dependency-checker-GGCv1.7.1.zip
cd greengrass-dependency-checker-GGCv1.7.1
sudo modprobe configs
chmod +700 check_ggc_dependencies
sudo ./check_ggc_dependencies | more

4

Create a Greengrass group.

  • On the AWS IoT console, click "Greengrass" on the left
  • Click "Create a group".


                            AWS IoT navigation pane with Greengrass highlighted.
                        Image RemovedImage Added

5
  • Select "use easy creation" to automatically generate certificates for the phyBoard-Zeta to connect to AWS Greengrass
  • Select "provision a core" in the IoT Registry


                            Set up your Greengrass Group console page with the Use easy
                                creation button highlighted.
                        Image RemovedImage Added

6Name your group in the "Group Name" box and click "Next".


                            The Name your Group page with MyFirstGroup in the Group Name
                                field and the Next button highlighted.
                        Image RemovedImage Added

7Use the name provided for the core, and click "Next".


                            The Every Group needs a Core to function page with
                                MyFirstGroup_Core in the Name field and the Next button
                                highlighted.
                        Image RemovedImage Added

8Click "Create Group and Core" to finalize creating the Greengrass Group (AWS-side resources for the your set of devices).


                            The Run a scripted easy Group creation page with the Create
                                Group and Core button highlighted.
                        Image RemovedImage Added

9On the confirmation page, download the certificate package. No need to download the software configuration package. Click "Finish".


                                    The Connect your Core device page with Download these resources
                                        as a tar.gz highlighted.
                                Image RemovedImage Added

10Transfer the certificate package from your computer to the i.MX7.

from Windows (not tested):

Code Block
cd <insert path-to-downloaded-files>
pscp <insert hash>-setup.tar.gz root@<insert IP-address>:~/Downloads

from macOS/Unix

Code Block
cd <insert path-to-downloaded-files>
sudo scp <insert hash>-setup.tar.gz root@<insert IP-address>:~/Downloads


11Return 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.


Code Block
cd ~/Downloads
tar -xzvf <insert hash-setup>.tar.gz -C /greengrass
cd /greengrass/certs/
wget -O root.ca.pem https://www.amazontrust.com/repository/AmazonRootCA1.pem


# Check that the last command was successful
cat root.ca.pem


12Start 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).


Code Block
cd /greengrass/ggc/core
sudo ./greengrassd start

# Check that daemon is running
ps aux | grep -E 'greengrass.*daemon'


13Create the "Hello World" Lambda function. Return to the AWS IoT Core Console and select "Software"


                            The navigation pane of the AWS IoT Core console page with Software
                                highlighted.
                        Image RemovedImage Added

14

Download the SDK:

  • Scroll down to "SDKs" and under "AWS IoT Greengrass Core SDK", select "
configure downloadChoose "Python 2.7 version 1.
  • View all SDKs"


                            The SDKs section with Configure download highlighted.
                        Image Removed

15
  • Click "v1.3.0"
and "Download
  • under "Python 2.7" to download the AWS IoT Greengrass Core SDK
"
  • for Python


                            Python 2.7 version 1.3.0 and Download Greengrass Core SDK.
                        Image RemovedImage Added Image Added

1615Decompress 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:

Code Block
tar -xzf <path to greengrass-core-python-sdk-1.3.0.tar.gz>/greengrass-core-python-sdk-1.3.0.tar.gz
cd aws_greengrass_core_sdk/sdk
sudo unzip python_sdk_1_3_0.zip


1716Now actually create the Lambda function. Move the greengrasssdk folder into the "examples"→ "HelloWorld" folder and zip them together.


                            Screenshot showing zipped contents of
                                hello_word_python_lambda.zip.
                        Image RemovedImage Added

Unix (including macOS):

Code Block
sudo zip -r hello_world_python_lambda.zip greengrasssdk greengrassHelloWorld.py

Windows:

1817Package the Lambda. On the group page in the AWS IoT Console, select "Lambda" → "Add Lambda" → "Create new Lambda".

1918In the AWS Lambda Console, fill out the "Author from Scratch" box like in the following screenshot, and then select "Create function" on the bottom:

Image RemovedImage Added

2019
  • Upload the Lambda function deployment package created in Step 17 (could be named something different)
  • Fill out the fields like in the image.


                                    Screenshot of the Configuration tab with Upload a .zip
                                        file, Python 2.7, greengrassHelloWorld.function_handler, and
                                        Upload highlighted.
                                Image RemovedImage Added

2120

Publish the Lambda function:

  • "Actions" → "Publish new version"
  • In "Version Description" , enter anything (e.g. "First version"and the then "Publish"


                                    Screenshot of the Actions menu with Publish new version
                                        highlighted.
                                Image RemovedImage Added


                            Screenshot with the Version description field set to First
                                version and the Publish button highlighted.
                        Image RemovedImage Added

2221

Create an alias/ nickname for the Lambda function:

  • "Actions" → "Create alias"
  • Enter a name (e.g. "GG_HelloWorld")
  • Set version to "1"
  • Click "Create"


                            Screenshot of the Actions menu set to Create alias.
                        Image RemovedImage Added


                            Screenshot of Create a new alias with the Name field set to
                                GG_HelloWorld, the Version field set to 1, and the Create button
                                highlighted.
                        Image RemovedImage Added

2322

Add the Lambda to your GG group to deploy:

  • Return to the group created in the AWS IoT Console
  • Choose "Use existing Lambda"
  • Select the Lambda created in the last step

Image RemovedImage Added


                            Screenshot of Use existing Lambda with Greengrass_HelloWorld and
                                the Next button highlighted.
                        Image RemovedImage Added

2423

Edit the Lambda's configuration for the group:

  • For version, choose "Alias: GG_HelloWorld", or whatever alias was chosen for the Lambda
  • Set the settings as the ones in the lower image
  • Choose "Update"


                            Screenshot of MyFirstGroup with the ellipsis and Edit
                                Configuration highlighted.
                        Image RemovedImage Added



                            Screenshot of the configuration page with 25 (seconds) and the
                                Make this function long-lived and keep it running indefinitely radio
                                button selected.
                        Image RemovedImage Added

2524

Create a subscription to the MQTT topic:

  • Choose "Subscriptions"
  • For "Select a source", choose "Select"
  • Choose the "Lambdas" tab and then "Greengrass_HelloWorld"
  • For "Select a target" choose "Select"
  • Choose the "Services" tab, and then choose "IoT Cloud", "Next"
  • In the "Topic filter" section, type "hello/world", and then hit "Next"


                            Screenshot of the Group configuration page, with Subscription
                                and Add your first Subscription highlighted.
                        Image RemovedImage Added


                            Screenshot of the Select a source page with Lambdas and
                                Greengrass_HelloWorld highlighted.
                        Image RemovedImage Added


Image RemovedImage Added

2625

Deploy the Lambda:

  • Select "Actions" → "Deploy"
    • The first time may take awhile
    • If deployment takes more than 20 - 30 minutes, try:
      • "Actions" → "Reset Deployments"
      • Check the box that says "Do you want to force the reset"
      • Click "Reset deployment"
      • Redeploy like before
  • The "Deployments" tab will contain a log of successes/failures, also indicated by the colored dot in the heading
  • Choose "Automatic detection" in the next window



                    Screenshot of the Group page with Deployments, Actions menu, and Deploy
                        highlighted.
                Image RemovedImage Added


                    Screenshot of Configure how Devices discover your Core with Automatic
                        detection highlighted.
                Image RemovedImage Added

2726

See the MQTT messages:

  • In the side bar of the AWS IoT Core console, choose "Test"
  • Choose "Subscribe to topic" in the left-hand column and set the settings to look like the lower image
  • Click Now click "Subscribe to topic" to the right of the "Subscription Topic" field


                    Screenshot of AWS IoT Core console with Test highlighted.
                Image RemovedImage Added


                    Screenshot of Subscriptions test page.
                Image RemovedImage Added

2827

There should now be a "Hello world!" MQTT message appearing in the AWS IoT test console every five or so seconds!


Image RemovedImage Added


...