Amazon IoT Greengrass Version 1 entered the extended life phase on June 30, 2023. For more information, see the Amazon IoT Greengrass V1 maintenance policy. After this date, Amazon IoT Greengrass V1 won't release updates that provide features, enhancements, bug fixes, or security patches. Devices that run on Amazon IoT Greengrass V1 won't be disrupted and will continue to operate and to connect to the cloud. We strongly recommend that you migrate to Amazon IoT Greengrass Version 2, which adds significant new features and support for additional platforms.
Test communications
-
On your computer, open two command-line
windows. Just as in Module 5, one window is for the GG_Switch client device and the other is for the GG_TrafficLight client device. You use them to run the same commands that you ran in Module 5. Run the following commands for the GG_Switch client device:
cd
path-to-certs-folder
python lightController.py --endpointAWS_IOT_ENDPOINT
--rootCA AmazonRootCA1.pem --certswitchCertId
-certificate.pem.crt --keyswitchCertId
-private.pem.key --thingName GG_TrafficLight --clientId GG_SwitchRun the following commands for the GG_TrafficLight client device:
cd
path-to-certs-folder
python trafficLight.py --endpointAWS_IOT_ENDPOINT
--rootCA AmazonRootCA1.pem --certlightCertId
-certificate.pem.crt --keylightCertId
-private.pem.key --thingName GG_TrafficLight --clientId GG_TrafficLightEvery 20 seconds, the switch updates the shadow state to G, Y, and R, and the light displays its new state.
-
The function handler of the Lambda function is triggered on every third green light (every three minutes), and a new DynamoDB record is created. After
lightController.py
andtrafficLight.py
have run for three minutes, go to the Amazon Web Services Management Console, and open the DynamoDB console. -
Choose US East (N. Virginia) in the Amazon Web Services Region menu. This is the Region where the
GG_Car_Aggregator
function creates the table. -
In the navigation pane, choose Tables, and then choose the CarStats table.
-
Choose View items to view the entries in the table.
You should see entries with basic statistics on cars passed (one entry for every three minutes). You might need to choose the refresh button to view updates to the table.
-
If the test is not successful, you can look for troubleshooting information in the Greengrass logs.
-
Switch to the root user and navigate to the
log
directory. Access to Amazon IoT Greengrass logs requires root permissions.sudo su cd /greengrass/ggc/var/log
-
Check
runtime.log
for errors.cat system/runtime.log | grep 'ERROR'
-
Check the log generated by the Lambda function.
cat user/
region
/account-id
/GG_Car_Aggregator.logThe
lightController.py
andtrafficLight.py
scripts store connection information in thegroupCA
folder, which is created in the same folder as the scripts. If you receive connection errors, make sure that the IP address in theggc-host
file matches the IP address endpoint for your core.
For more information, see Troubleshooting Amazon IoT Greengrass.
-
This is the end of the basic tutorial. You should now understand the Amazon IoT Greengrass programming model and its fundamental concepts, including Amazon IoT Greengrass cores, groups, subscriptions, client devices, and the deployment process for Lambda functions running at the edge.
You can delete the DynamoDB table and the Greengrass Lambda functions and subscriptions. To stop communications between the Amazon IoT Greengrass core device and the Amazon IoT cloud, open a terminal on the core device and run one of the following commands:
-
To shut down the Amazon IoT Greengrass core device:
sudo halt
-
To stop the Amazon IoT Greengrass daemon:
cd /greengrass/ggc/core/ sudo ./greengrassd stop