Lab 1 - AWS IoT Button
A couple years ago, AWS announced the AWS IoT Button you could order from Amazon.com. Why not create our own?
For this lab, our M5StickC will act as an AWS IoT Button, allowing you to trigger downstream AWS Services.
Configuration
In order to configure the code and your M5StickC for Lab1, you must change the following lines of code:
In file: ~/environment/workshop/amazon-freertos/vendors/espressif/boards/m5stickc/aws_demos/application_code/m5stickc_lab_config.h
Replace:
#define M5CONFIG_LAB0_DEEP_SLEEP_BUTTON_WAKEUP
With:
#define M5CONFIG_LAB1_AWS_IOT_BUTTON
Rebuild Code
cd ~/environment/workshop/amazon-freertos/vendors/espressif/boards/m5stickc/aws_demos
make all -j4
Flash Code
Please follow the same procedure from Flash the firmware files.
Result
Log into your AWS IoT Management console, use the web MQTT client and subscribe to the following topic:
m5stickc/+
Click your M5StickC button: You should see the following JSON document flow on the broker
{
"serialNumber": "[YOUR DEVICE SERIAL NUMBER]",
"clickType": "SINGLE"
}
Hold your M5StickC button: You should see the following JSON document flow on the broker
{
"serialNumber": "[YOUR DEVICE SERIAL NUMBER]",
"clickType": "HOLD"
}
Done
You are done with Lab 1.
Knowledge check
- Q1: m5stickc/+, what does the ”+” do?
- Q2: What can you replace ”+” with?
Challenge
- Can you create an AWS IoT Rule that gets triggered on a button press and sends your cell phone an SMS?
- Can you make that rule ONLY send you an SMS if you HOLD the button?
- Can you modify the AWS IoT Policy you created in prior steps to limit communications to only the required topics?