mirror of
https://github.com/m5stack/aws-iot-kit-tutorials.git
synced 2026-05-20 10:49:00 -07:00
Init
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
## Code of Conduct
|
||||
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
|
||||
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
|
||||
opensource-codeofconduct@amazon.com with any additional questions or comments.
|
||||
opensource-codeofconduct@amazon.com with any additional questions or comments.
|
||||
+1
-1
@@ -56,4 +56,4 @@ If you discover a potential security issue in this project we ask that you notif
|
||||
|
||||
## Licensing
|
||||
|
||||
See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
|
||||
See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
|
||||
@@ -12,4 +12,3 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
@@ -1,17 +1,72 @@
|
||||
## My Project
|
||||
# AWS IoT EduKit Tutorials
|
||||
This repository contains the tutorial content for the AWS IoT EduKit program. To view the AWS IoT EduKit content live and learn more about the program, visit (https://edukit.workshop.aws)[https://edukit.workshop.aws].
|
||||
|
||||
TODO: Fill this README out!
|
||||
## Repo structure
|
||||
```bash
|
||||
.
|
||||
├── metadata.yml <-- Metadata file with descriptive information about the workshop
|
||||
├── README.md <-- This instructions file
|
||||
├── deck <-- Directory for presentation deck
|
||||
├── resources <-- Directory for workshop resources
|
||||
│ ├── code <-- Directory for workshop modules code
|
||||
│ ├── policies <-- Directory for workshop modules IAM Roles and Policies
|
||||
│ └── templates <-- Directory for workshop modules CloudFormation templates
|
||||
└── workshop
|
||||
├── config.toml <-- Hugo configuration file for the workshop website
|
||||
└── content <-- Markdown files for pages/steps in workshop
|
||||
└── static <-- Any static assets to be hosted alongside the workshop (ie. images, scripts, documents, etc)
|
||||
└── themes <-- AWS Style Hugo Theme (Do not edit!)
|
||||
```
|
||||
|
||||
Be sure to:
|
||||
## What's Included
|
||||
This project the following folders:
|
||||
|
||||
* Change the title in this README
|
||||
* Edit your repository description on GitHub
|
||||
* `deck`: Future location to store presentation materials. Currently unused.
|
||||
* `resources`: Future location to store any example code, IAM policies, or Cloudformation templates. Currently unused.
|
||||
* `workshop`: This is the core workshop folder. This is generated as HTML and hosted for presentation for customers.
|
||||
|
||||
## Security
|
||||
|
||||
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
|
||||
## Requirements to web application locally
|
||||
1. [Clone this repository](https://help.github.com/articles/fork-a-repo/).
|
||||
2. [Install Hugo locally](https://gohugo.io/overview/quickstart/). As of 1 Mar 2020, the workshop.aws build process uses [Hugo 0.64.1](https://github.com/gohugoio/hugo/releases/tag/v0.64.1)
|
||||
|
||||
## License
|
||||
|
||||
This library is licensed under the MIT-0 License. See the LICENSE file.
|
||||
# Running the web application locally
|
||||
## Navigate to the `workshop` directory
|
||||
All command line directions in this documentation assume you are in the `workshop` directory. Navigate there now, if you aren't there already.
|
||||
|
||||
```bash
|
||||
cd aws-iot-edukit-tutorials/workshop
|
||||
```
|
||||
|
||||
## Launching the website locally
|
||||
Launch by using the following command:
|
||||
|
||||
```bash
|
||||
hugo serve
|
||||
```
|
||||
|
||||
Go to `http://localhost:1313` in your browser
|
||||
|
||||
You should notice three things:
|
||||
|
||||
1. You have a left-side **Intro** menu, containing two submenus with names equal to the `title` properties in the previously created files.
|
||||
2. The home page explains how to customize it by following the instructions.
|
||||
3. When you run `hugo server`, when the contents of the files change, the page automatically refreshes with the changes. Neat!
|
||||
|
||||
Alternatively, you can run the following command in a terminal window to tell Hugo to automatically rebuild whenever a file is changed. This can be helpful when rapidly iterating over content changes.
|
||||
|
||||
```bash
|
||||
hugo server
|
||||
```
|
||||
|
||||
## Adding language translations:
|
||||
To add additional languages, update the config.toml with the language you're adding.
|
||||
The example below demonstrates how to add French language translations. To add individual pages in French, go to the corresponding tutorial and section directory in the **workshop/content** folder and add a new file following the pattern `_index.<<language extention>>.md`. So to match the config.toml example below for french, the page filename would be **_index.fr.md**.
|
||||
|
||||
```
|
||||
[Languages.fr]
|
||||
title = "Mon atelier AWS"
|
||||
weight = 2
|
||||
languageName = "Français"
|
||||
```
|
||||
@@ -0,0 +1,29 @@
|
||||
#name - DNS-friendly name for the workshop. This will be used when generating the hosting URL (ie. https://my-first-workshop.workshops.aws/)
|
||||
name: edukit
|
||||
#title - The title of your workshop
|
||||
title: AWS IoT EduKit
|
||||
#description - A short description that will be displayed in search results
|
||||
description: AWS IoT EduKit is a prescriptive learning program for developers. With AWS IoT EduKit, students working on their first IoT project, professionals who want to learn more about IoT, and engineers who want to develop new IoT skills, can use a reference hardware kit and self-service tutorials for a hands-on introduction to building IoT applications.
|
||||
#categories - Refer to official AWS categories covered by the workshop content here
|
||||
categories:
|
||||
- IoT
|
||||
- Alexa
|
||||
#services - Refer to the official AWS service names covered by the workshop content here
|
||||
services:
|
||||
- IoT Core
|
||||
- IoT Analytics
|
||||
- Amazon Sagemaker Autopilot
|
||||
- Alexa
|
||||
#level - Approximate skill level needed for this workshop
|
||||
level: 100
|
||||
#duration - Estimated duration in minutes
|
||||
duration: 360
|
||||
#cost - Cost in USD. If the content is offered without cost, enter 0
|
||||
cost: 0
|
||||
#author - Amazon alias of the primary author of the content
|
||||
author: trashed, burkery, erifahsl
|
||||
#audience - Names of the personas associated with this workshop
|
||||
audience:
|
||||
- IT Professional
|
||||
- Developer
|
||||
- Student
|
||||
@@ -0,0 +1,71 @@
|
||||
RelativeURLs=true
|
||||
CanonifyURLs=true
|
||||
languageCode = "en-US"
|
||||
defaultContentLanguage = "en"
|
||||
|
||||
title = "AWS IoT EduKit"
|
||||
theme = "learn"
|
||||
metaDataFormat = "yaml"
|
||||
defaultContentLanguageInSubdir= true
|
||||
|
||||
uglyurls = true
|
||||
sectionPagesMenu = "main"
|
||||
pygmentsCodeFences = true
|
||||
pygmentsStyle = "monokai"
|
||||
|
||||
[params]
|
||||
description = "AWS IoT EduKit"
|
||||
author = "Rashed Talukder, Ryan Burke, Z Sun, Eric Fahsl"
|
||||
disableBreadcrumb = false
|
||||
disableNextPrev = false
|
||||
themeVariant = "aws"
|
||||
disableSearch = false
|
||||
disableAssetsBusting = true
|
||||
disableLanguageSwitchingButton = false
|
||||
disableShortcutsTitle = true
|
||||
disableInlineCopyToClipBoard = true
|
||||
|
||||
[outputs]
|
||||
home = [ "HTML", "RSS", "JSON"]
|
||||
|
||||
[markup]
|
||||
defaultMarkdownHandler = "goldmark"
|
||||
[markup.goldmark]
|
||||
[markup.goldmark.renderer]
|
||||
unsafe = true
|
||||
|
||||
[Languages]
|
||||
[Languages.en]
|
||||
title = "AWS IoT EduKit"
|
||||
weight = 1
|
||||
languageName = "English"
|
||||
[Languages.en_uk]
|
||||
title = "AWS IoT EduKit"
|
||||
weight = 2
|
||||
languageName = "English UK"
|
||||
|
||||
#
|
||||
|
||||
[menu]
|
||||
[[menu.main]]
|
||||
identifier = " "
|
||||
name = " "
|
||||
title = " "
|
||||
url = "/"
|
||||
weight = -110
|
||||
|
||||
[[menu.shortcuts]]
|
||||
name = "<i class='fab fa-github'></i> GitHub Repository (<i class='fas fa-sync-alt fa-xs'></i> Jan 19, 2021)"
|
||||
url = "https://github.com/m5stack/Core2-for-AWS-IoT-EduKit"
|
||||
weight = 1
|
||||
|
||||
[[menu.shortcuts]]
|
||||
name = "<i class='fas fa-question-circle'></i> Community Support"
|
||||
url = "https://community.m5stack.com/category/41/core2-for-aws"
|
||||
weight = 2
|
||||
|
||||
[[menu.shortcuts]]
|
||||
name = "<i class='fas fa-bug'></i> Report Bugs"
|
||||
url = "https://github.com/m5stack/Core2-for-AWS-IoT-EduKit/issues"
|
||||
weight = 3
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
+++
|
||||
title = "Blinking the LEDs"
|
||||
weight = 40
|
||||
pre = "<b>d. </b>"
|
||||
+++
|
||||
|
||||
At this point, your device software is running and you are connected to AWS IoT Core, are sending messages, and are ready to receive and act on messages from the cloud. In this chapter, you will subscribe to an MQTT topic, view the messages coming into AWS IoT Core, and send a message to blink your device LEDs. Since MQTT is a publish-subscribe protocol, you can subscribe and/or publish to specific topics. The policy that was set earlier in the registration script constrained the topics that the device can subscribe and publish to. This is critical for filtering, and potentially for security. Your device can only send or receive to topics that matches the client Id, which in this case is the same as the unique serial number of the device's secure element.
|
||||
|
||||
## Subscribing via the AWS IoT MQTT client
|
||||
The AWS IoT MQTT client in the AWS IoT Core console allows you to both view and publish MQTT messages. To start, go to [AWS IoT console](https://us-west-2.console.aws.amazon.com/iot/home?region=us-west-2#/) and choose **Test** to open the client view.
|
||||
|
||||
{{< img "choose-test.png" "Choose test in AWS IoT console" >}}
|
||||
|
||||
In the **Subscription topic** field, enter `#` to subscribe to all MQTT topic names. The multi-level wild card [topic filter](https://docs.aws.amazon.com/iot/latest/developerguide/topics.html#topicfilters) is **#** and can only be used once as the last character of a topic filter. Once you press the **Subscribe to topic** button, you will see messages being sent from your device. The device is only allowed to publish messages to the topic beginning with `<<CLIENT_ID>>/`. This gives the ability for another subscriber (e.g. Cloud application) to filter topics for specific client devices, and can also be narrowed to be more specific topics (e.g. temperature reading of a specific device).
|
||||
|
||||
## Blinking the LED
|
||||
To start/stop the blinking of the LED bars on the sides of the M5Stack Core2 for AWS IoT EduKit reference hardware, we're going to publish from the console's AWS IoT MQTT client on a topic that the Core2 for AWS IoT EduKit is subscribed to. To do so, we first need to get the device's client Id. Going back to the shell prompt where the serial monitor is still running, copy the **client Id**.
|
||||
|
||||
{{% notice note %}}
|
||||
If you do not see **(edukit)** prefix at your shell prompt, ensure you activate your conda environment by running `conda activate edukit`.
|
||||
If the idf.py command is not found, add the ESP-IDF to your path with the command `. $HOME/esp/esp-idf/export.sh` (macOS/Linux) or `%userprofile%\Desktop\esp-idf\export.bat` (Windows).
|
||||
{{% /notice %}}
|
||||
|
||||
In the Publish box, enter the command below, but replacing the **<<CLIENT_ID>>** text with your actual client Id that was just copied and then press the **Publish to topic** button:
|
||||
```
|
||||
<<CLIENT_ID>>/blink
|
||||
```
|
||||
{{< img "aws_iot_mqtt_client.png" "Subscribing to messages and publishing with AWS IoT console MQTT client" >}}
|
||||
Your device should now have the side bar LEDs blinking. To pause the blinking, simply press the **Publish to topic** button again to the same topic and it will pause the blinking task that was looping the LEDs on and off. These tasks are part of the FreeRTOS kernel (can also be thought of as threads) that should perform a single task in a loop. The FreeRTOS kernel gives microcontroller applications the ability to optimize the processor by scheduling individual tasks to run once another task has put itself into a suspended or blocked state (e.g. with **vTaskSuspend** or **vTaskDelay**). Learn more about about scheduling with FreeRTOS [here](https://www.freertos.org/implementation/a00005.html).
|
||||
|
||||
{{% notice info %}}
|
||||
To exit out of the serial monitor, press **CTRL** + **]**.
|
||||
{{% /notice %}}
|
||||
|
||||
## Cleaning up
|
||||
To optimize resources used and avoid unwanted possible AWS Cloud service charges, you will be erasing the flash on your device to get it ready for the subsequent tutorials. To erase the flash, you'll need to be in a project that has already been built (such as the one you just completed), exit a running serial monitor that might block the port (press **CTRL** + **]**), and use the command:
|
||||
|
||||
```
|
||||
idf.py erase_flash -p <<DEVICE_PORT>>
|
||||
```
|
||||
|
||||
## Conclusion
|
||||
Hopefully you enjoyed the journey of building your cloud connected blinky project. Using Espressif's toolchain (ESP-IDF), you were able to build, flash, and monitor your Core2 for AWS IoT EduKit's firmware. Your device is now registered as an AWS IoT thing with AWS for secure cloud connectivity using embedded device certificates and private keys that can never leave the device. You connected to AWS IoT Core, sent messages from the device over MQTT, and received an MQTT message from the AWS IoT console's MQTT client which was used to toggle the lights on the device.
|
||||
|
||||
|
||||
On to the next tutorial, [**Smart Thermostat**](/en/smart-thermostat.html).
|
||||
|
||||
---
|
||||
{{% button href="https://github.com/m5stack/Core2-for-AWS-IoT-EduKit/issues" icon="fas fa-bug" %}}Report bugs{{% /button %}} {{% button href="https://community.m5stack.com/category/41/core2-for-aws" icon="far fa-question-circle" %}}Community support{{% /button %}}
|
||||
@@ -0,0 +1,49 @@
|
||||
+++
|
||||
title = "Blinking the LEDs"
|
||||
weight = 40
|
||||
pre = "<b>d. </b>"
|
||||
+++
|
||||
|
||||
At this point, your device software is running and you are connected to AWS IoT Core, are sending messages, and are ready to receive and act on messages from the cloud. In this chapter, you will subscribe to an MQTT topic, view the messages coming into AWS IoT Core, and send a message to blink your device LEDs. Since MQTT is a publish-subscribe protocol, you can subscribe and/or publish to specific topics. The policy that was set earlier in the registration script constrained the topics that the device can subscribe and publish to. This is critical for filtering, and potentially for security. Your device can only send or receive to topics that matches the client Id, which in this case is the same as the unique serial number of the device's secure element.
|
||||
|
||||
## Subscribing via the AWS IoT MQTT client
|
||||
The AWS IoT MQTT client in the AWS IoT Core console allows you to both view and publish MQTT messages. To start, go to [AWS IoT console](https://us-west-2.console.aws.amazon.com/iot/home?region=us-west-2#/) and choose **Test** to open the client view.
|
||||
|
||||
{{< img "choose-test.png" "Choose test in AWS IoT console" >}}
|
||||
|
||||
In the **Subscription topic** field, enter `#` to subscribe to all MQTT topic names. The multi-level wild card [topic filter](https://docs.aws.amazon.com/iot/latest/developerguide/topics.html#topicfilters) is **#** and can only be used once as the last character of a topic filter. Once you press the **Subscribe to topic** button, you will see messages being sent from your device. The device is only allowed to publish messages to the topic beginning with `<<CLIENT_ID>>/`. This gives the ability for another subscriber (e.g. Cloud application) to filter topics for specific client devices, and can also be narrowed to be more specific topics (e.g. temperature reading of a specific device).
|
||||
|
||||
## Blinking the LED
|
||||
To start/stop the blinking of the LED bars on the sides of the M5Stack Core2 for AWS IoT EduKit reference hardware, we're going to publish from the console's AWS IoT MQTT client on a topic that the Core2 for AWS IoT EduKit is subscribed to. To do so, we first need to get the device's client Id. Going back to the shell prompt where the serial monitor is still running, copy the **client Id**.
|
||||
|
||||
{{% notice note %}}
|
||||
If you do not see **(edukit)** prefix at your shell prompt, ensure you activate your conda environment by running `conda activate edukit`.
|
||||
If the idf.py command is not found, add the ESP-IDF to your path with the command `. $HOME/esp/esp-idf/export.sh` (macOS/Linux) or `%userprofile%\Desktop\esp-idf\export.bat` (Windows).
|
||||
{{% /notice %}}
|
||||
|
||||
In the Publish box, enter the command below, but replacing the **<<CLIENT_ID>>** text with your actual client Id that was just copied and then press the **Publish to topic** button:
|
||||
```
|
||||
<<CLIENT_ID>>/blink
|
||||
```
|
||||
{{< img "aws_iot_mqtt_client.png" "Subscribing to messages and publishing with AWS IoT console MQTT client" >}}
|
||||
Your device should now have the side bar LEDs blinking. To pause the blinking, simply press the **Publish to topic** button again to the same topic and it will pause the blinking task that was looping the LEDs on and off. These tasks are part of the FreeRTOS kernel (can also be thought of as threads) that should perform a single task in a loop. The FreeRTOS kernel gives microcontroller applications the ability to optimize the processor by scheduling individual tasks to run once another task has put itself into a suspended or blocked state (e.g. with **vTaskSuspend** or **vTaskDelay**). Learn more about about scheduling with FreeRTOS [here](https://www.freertos.org/implementation/a00005.html).
|
||||
|
||||
{{% notice info %}}
|
||||
To exit out of the serial monitor, press **CTRL** + **]**.
|
||||
{{% /notice %}}
|
||||
|
||||
## Cleaning up
|
||||
To optimize resources used and avoid unwanted possible AWS Cloud service charges, you will be erasing the flash on your device to get it ready for the subsequent tutorials. To erase the flash, you'll need to be in a project that has already been built (such as the one you just completed), exit a running serial monitor that might block the port (press **CTRL** + **]**), and use the command:
|
||||
|
||||
```
|
||||
idf.py erase_flash -p <<DEVICE_PORT>>
|
||||
```
|
||||
|
||||
## Conclusion
|
||||
Hopefully you enjoyed the journey of building your cloud connected blinky project. Using Espressif's toolchain (ESP-IDF), you were able to build, flash, and monitor your Core2 for AWS IoT EduKit's firmware. Your device is now registered as an AWS IoT thing with AWS for secure cloud connectivity using embedded device certificates and private keys that can never leave the device. You connected to AWS IoT Core, sent messages from the device over MQTT, and received an MQTT message from the AWS IoT console's MQTT client which was used to toggle the lights on the device.
|
||||
|
||||
|
||||
On to the next tutorial, [**Smart Thermostat**](/en_uk/smart-thermostat.html).
|
||||
|
||||
---
|
||||
{{% button href="https://github.com/m5stack/Core2-for-AWS-IoT-EduKit/issues" icon="fas fa-bug" %}}Report bugs{{% /button %}} {{% button href="https://community.m5stack.com/category/41/core2-for-aws" icon="far fa-question-circle" %}}Community support{{% /button %}}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 75 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
@@ -0,0 +1,53 @@
|
||||
+++
|
||||
title = "Connecting to AWS IoT Core"
|
||||
weight = 30
|
||||
pre = "<b>c. </b>"
|
||||
+++
|
||||
|
||||
In this chapter you'll configure, build, and flash your device firmware—which will connect to AWS IoT Core. In order to connect and communicate to AWS IoT Core, you need to configure your device with Wi-Fi credentials and the URL of your AWS endpoint. Connectivity is simplified with the pre-provisioned certificates in the Microchip ATECC608 Trust&GO, which is assigned to our AWS IoT thing and attached to a security policy from the previous chapter. You do not need to retrieve certificates from AWS IoT Core or generate your own. To configure, build, and flash our firmware on to the Espressif ESP32-D0WD you will use the ESP-IDF.
|
||||
|
||||
## Configuring the ESP32 Firmware
|
||||
Configuration of your source code is handled through [Kconfig](https://www.kernel.org/doc/html/latest/kbuild/kconfig-language.html). Kconfig is the same configuration system used by the Linux kernel and helps simplify available configuration options (symbols) into a tree structure. Before you set the configuration, you will first need to retrieve your AWS IoT endpoint.
|
||||
|
||||
```bash
|
||||
aws iot describe-endpoint --endpoint-type iot:Data-ATS
|
||||
```
|
||||
Copy your AWS IoT endpoint without the quotes. It will look something like `3duk1t3xampl3.iot.us-west-2.amazonaws.com`. We'll use this in a moment.
|
||||
|
||||
You can enter the configuration menu from the **Blink-Hello-World** directory of the repository:
|
||||
```bash
|
||||
idf.py menuconfig
|
||||
```
|
||||
{{< img "hello_world-menuconfig.webp" "Configuring Core2 for AWS IoT EduKit with idf.py menuconfig" >}}
|
||||
Here you will set the configuration. Use the direction keys on your keyboard to go to **Component config** --> **Amazon Web Services IoT Platform** and open **AWS IoT Endpoint Hostname** to set the string. You can paste the address you copied moments ago into the box and hit _enter_ to set that symbol. Next, go back to the configuration home screen by pressing the *ESC* key twice. Then select **AWS IoT EduKit Configuration** from the menu. Set your **WiFi SSID** and **WiFi Password** with your Wi-FI credentials. Once you are finished, press the *s* button on your keyboard to save, confirm the location of the file by pressing *enter*, followed by *q* to quit.
|
||||
|
||||
{{% notice warning %}}
|
||||
Be sure your SSID is for a 2.4GHz network. The ESP32-D0WD on the M5Stack Core2 for AWS hardware does not support 5GHz Wi-Fi bands.
|
||||
{{% /notice %}}
|
||||
|
||||
## Building the ESP32 Firmware
|
||||
Building the firmware is easy, but can take quite a while the first time. ESP-IDF uses CMAKE as it's build system and will link all the files necessary and begin compiling the code to a flashable binary in ELF format that can be flashed on to the device.
|
||||
```bash
|
||||
idf.py build
|
||||
```
|
||||
|
||||
## Erasing Old Firmware
|
||||
If you completed the Getting Started or Alexa demo, it is recommended to erase the flash memory of your device. The flash is split into separate partitions where the application data, OTA data, and keys are stored. The other walk-throughs use a different partition table than used for this tutorial and could cause issues if not wiped. Replace **<<DEVICE_PORT>>** with the serial port your Core2 for AWS IoT EduKit device is connected to:
|
||||
```bash
|
||||
idf.py erase_flash -p <<DEVICE_PORT>>
|
||||
```
|
||||
|
||||
## Flashing the ESP32 Firmware and monitoring the device output over the serial port
|
||||
To flash the firmware you just built and view all the outputs by the device over the serial connection, you're going to daisy chain commands and enter:
|
||||
```bash
|
||||
idf.py flash monitor -p <<DEVICE_PORT>>
|
||||
```
|
||||
Once the device is flashed, it will reboot and run the application. You should see the device connect to your Wi-Fi network, establish a secure MQTT connection to AWS IoT Core, subscribe to the preset MQTT topic, and begin sending messages.
|
||||
|
||||
## Chapter conclusion
|
||||
In this chapter, you have successfully compiled and flash your device and are actively monitoring it's serial outputs. Using the AWS IoT Device SDK for Embedded C, the reference hardware authenticated with the MQTT message broker (AWS IoT Core) and is ready to receive messages.
|
||||
|
||||
You are now ready to head to the final chapter in this tutorial, [**Blinking the LED**](/en/blinky-hello-world/blinking-the-leds.html).
|
||||
|
||||
---
|
||||
{{% button href="https://github.com/m5stack/Core2-for-AWS-IoT-EduKit/issues" icon="fas fa-bug" %}}Report bugs{{% /button %}} {{% button href="https://community.m5stack.com/category/41/core2-for-aws" icon="far fa-question-circle" %}}Community support{{% /button %}}
|
||||
@@ -0,0 +1,53 @@
|
||||
+++
|
||||
title = "Connecting to AWS IoT Core"
|
||||
weight = 30
|
||||
pre = "<b>c. </b>"
|
||||
+++
|
||||
|
||||
In this chapter you'll configure, build, and flash your device firmware—which will connect to AWS IoT Core. In order to connect and communicate to AWS IoT Core, you need to configure your device with Wi-Fi credentials and the URL of your AWS endpoint. Connectivity is simplified with the pre-provisioned certificates in the Microchip ATECC608 Trust&GO, which is assigned to our AWS IoT thing and attached to a security policy from the previous chapter. You do not need to retrieve certificates from AWS IoT Core or generate your own. To configure, build, and flash our firmware on to the Espressif ESP32-D0WD you will use the ESP-IDF.
|
||||
|
||||
## Configuring the ESP32 Firmware
|
||||
Configuration of your source code is handled through [Kconfig](https://www.kernel.org/doc/html/latest/kbuild/kconfig-language.html). Kconfig is the same configuration system used by the Linux kernel and helps simplify available configuration options (symbols) into a tree structure. Before you set the configuration, you will first need to retrieve your AWS IoT endpoint.
|
||||
|
||||
```bash
|
||||
aws iot describe-endpoint --endpoint-type iot:Data-ATS
|
||||
```
|
||||
Copy your AWS IoT endpoint without the quotes. It will look something like `3duk1t3xampl3.iot.us-west-2.amazonaws.com`. We'll use this in a moment.
|
||||
|
||||
You can enter the configuration menu from the **Blink-Hello-World** directory of the repository:
|
||||
```bash
|
||||
idf.py menuconfig
|
||||
```
|
||||
{{< img "hello_world-menuconfig.webp" "Configuring Core2 for AWS IoT EduKit with idf.py menuconfig" >}}
|
||||
Here you will set the configuration. Use the direction keys on your keyboard to go to **Component config** --> **Amazon Web Services IoT Platform** and open **() AWS IoT Endpoint Hostname** to set the string. You can paste the address you copied moments ago into the box and hit `enter` to set that symbol. Next, go back to the configuration home screen by pressing the `ESC` key *twice*. Then select `AWS IoT EduKit Configuration` from the menu. Set your **() WiFi SSID** and **() WiFi Password** with your Wi-FI credentials. Once you are finished, press the `s` button on your keyboard to save, confirm the location of the file by hitting `enter`, followed by `q` to quit.
|
||||
|
||||
{{% notice warning %}}
|
||||
Be sure your SSID is for a 2.4GHz network. The ESP32-D0WD on the M5Stack Core2 for AWS hardware does not support 5GHz Wi-Fi bands.
|
||||
{{% /notice %}}
|
||||
|
||||
## Building the ESP32 Firmware
|
||||
Building the firmware is easy, but can take quite a while the first time. ESP-IDF uses CMAKE as it's build system and will link all the files necessary and begin compiling the code to a flashable binary in ELF format that can be flashed on to the device.
|
||||
```bash
|
||||
idf.py build
|
||||
```
|
||||
|
||||
## Erasing Old Firmware
|
||||
If you completed the Getting Started or Alexa demo, it is recommended to erase the flash memory of your device. The flash is split into separate partitions where the application data, OTA data, and keys are stored. The other walk-throughs use a different partition table than used for this tutorial and could cause issues if not wiped. Replace **<<DEVICE_PORT>>** with the serial port your Core2 for AWS IoT EduKit device is connected to:
|
||||
```bash
|
||||
idf.py erase_flash -p <<DEVICE_PORT>>
|
||||
```
|
||||
|
||||
## Flashing the ESP32 Firmware and monitoring the device output over the serial port
|
||||
To flash the firmware you just built and view all the outputs by the device over the serial connection, you're going to daisy chain commands and enter:
|
||||
```bash
|
||||
idf.py flash monitor -p <<DEVICE_PORT>>
|
||||
```
|
||||
Once the device is flashed, it will reboot and run the application. You should see the device connect to your Wi-Fi network, establish a secure MQTT connection to AWS IoT Core, subscribe to the preset MQTT topic, and begin sending messages.
|
||||
|
||||
## Chapter conclusion
|
||||
In this chapter, you have successfully compiled and flash your device and are actively monitoring it's serial outputs. Using the AWS IoT Device SDK for Embedded C, the reference hardware authenticated with the MQTT message broker (AWS IoT Core) and is ready to receive messages.
|
||||
|
||||
You are now ready to head to the final chapter in this tutorial, [**Blinking the LED**](/en_uk/blinky-hello-world/blinking-the-leds.html).
|
||||
|
||||
---
|
||||
{{% button href="https://github.com/m5stack/Core2-for-AWS-IoT-EduKit/issues" icon="fas fa-bug" %}}Report bugs{{% /button %}} {{% button href="https://community.m5stack.com/category/41/core2-for-aws" icon="far fa-question-circle" %}}Community support{{% /button %}}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 222 KiB |
@@ -0,0 +1,41 @@
|
||||
+++
|
||||
title = "Device Provisioning"
|
||||
weight = 20
|
||||
pre = "<b>b. </b>"
|
||||
+++
|
||||
|
||||
In this chapter, you'll provision the device for connectivity to AWS IoT Core using the on-board Microchip ATTECC608 Trust&GO secure element to establish a TLS connection. The built-in hardware root of trust allows you to have a simplified and expedited provisioning path while never exposing the private key. You can retrieve the device certificate that is built into the device and create a manifest file to create a AWS IoT thing (a representation and record of your device). This device's client Id will be registered and identified in AWS IoT Core by the secure element serial number. You can use similar processes to automate the fleet deployment of thousands or millions of devices at a time.
|
||||
|
||||
## Identifying the serial port on host machine
|
||||
Please reference [Espressif's offical doc for establishing serial connections with the ESP32](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/establish-serial-connection.html). The port of your device will vary based on your OS. For macOS, the device is typically on `/dev/cu.SLAB_USBtoUART`. For Linux, the device is typically on `/dev/ttyUSB0` (user needs to be added to dialout group). For Windows, it will start with a `COM` and end with a number.
|
||||
|
||||
## Retrieving the Device Certificate and Registering your AWS IoT thing
|
||||
We have simplified the process of retrieving the device certificate from the Core2 for AWS IoT EduKit reference hardware's secure element, generating a device manifest by signing the device certificate with a x.509 certificate (includes your AWS IoT registration code), registering the device in AWS IoT with the device certificate, and attaching a secure policy to the AWS IoT thing.
|
||||
|
||||
Go into the project's AWS IoT registration helper directory and install necessary dependencies with pip:
|
||||
```bash
|
||||
cd Core2-for-AWS-IoT-EduKit/Blinky-Hello-World/utilities/AWS_IoT_registration_helper/
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
|
||||
Next, you'll need to run the Python script that executes all the steps for registering the device to your AWS account. Be sure to first replace **<<DEVICE_PORT>>** with the serial port your Core2 for AWS IoT EduKit device is connected to:
|
||||
```bash
|
||||
python registration_helper.py -p <<DEVICE_PORT>>
|
||||
```
|
||||
|
||||
{{% notice info %}}
|
||||
If you close your shell or open a new shell, you'll need to re-enter `conda activate edukit` to reactivate the virtual environment and run ESP-IDF's `export.sh` (macOS/Linux) or `export.bat` (Windows) to re-add the ESP-IDF tools to your path each time.
|
||||
{{% /notice %}}
|
||||
|
||||
With the device successfully registered and provisioned in AWS IoT, go back to the **Blinky-Hello-World** directory by entering:
|
||||
```bash
|
||||
cd ../..
|
||||
```
|
||||
|
||||
## Chapter Conclusion
|
||||
In this chapter, you used the secure element to create an AWS IoT [thing](https://docs.aws.amazon.com/iot/latest/developerguide/thing-registry.html), set up a permissions [policy](https://docs.aws.amazon.com/iot/latest/developerguide/thing-policy-variables.html) for your thing, and attached the device certificate to it. All of this was done without ever exposing the secret private key and removing a potential avenue for it to be compromised.
|
||||
|
||||
On to [**Connecting to AWS IoT Core**](connecting-to-aws.html).
|
||||
|
||||
---
|
||||
{{% button href="https://github.com/m5stack/Core2-for-AWS-IoT-EduKit/issues" icon="fas fa-bug" %}}Report bugs{{% /button %}} {{% button href="https://community.m5stack.com/category/41/core2-for-aws" icon="far fa-question-circle" %}}Community support{{% /button %}}
|
||||
@@ -0,0 +1,41 @@
|
||||
+++
|
||||
title = "Device Provisioning"
|
||||
weight = 20
|
||||
pre = "<b>b. </b>"
|
||||
+++
|
||||
|
||||
In this chapter, you'll provision the device for connectivity to AWS IoT Core using the on-board Microchip ATTECC608 Trust&GO secure element to establish a TLS connection. The built-in hardware root of trust allows you to have a simplified and expedited provisioning path while never exposing the private key. You can retrieve the device certificate that is built into the device and create a manifest file to create a AWS IoT thing (a representation and record of your device). This device's client Id will be registered and identified in AWS IoT Core by the secure element serial number. You can use similar processes to automate the fleet deployment of thousands or millions of devices at a time.
|
||||
|
||||
## Identifying the serial port on host machine
|
||||
Please reference [Espressif's offical doc for establishing serial connections with the ESP32](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/establish-serial-connection.html). The port of your device will vary based on your OS. For macOS, the device is typically on `/dev/cu.SLAB_USBtoUART`. For Linux, the device is typically on `/dev/ttyUSB0` (user needs to be added to dialout group). For Windows, it will start with a `COM` and end with a number.
|
||||
|
||||
## Retrieving the Device Certificate and Registering your AWS IoT thing
|
||||
We have simplified the process of retrieving the device certificate from the Core2 for AWS IoT EduKit reference hardware's secure element, generating a device manifest by signing the device certificate with a x.509 certificate (includes your AWS IoT registration code), registering the device in AWS IoT with the device certificate, and attaching a secure policy to the AWS IoT thing.
|
||||
|
||||
Go into the project's AWS IoT registration helper directory and install necessary dependencies with pip:
|
||||
```bash
|
||||
cd Core2-for-AWS-IoT-EduKit/Blinky-Hello-World/utilities/AWS_IoT_registration_helper/
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
|
||||
Next, you'll need to run the Python script that executes all the steps for registering the device to your AWS account. Be sure to first replace **<<DEVICE_PORT>>** with the serial port your Core2 for AWS IoT EduKit device is connected to:
|
||||
```bash
|
||||
python registration_helper.py -p <<DEVICE_PORT>>
|
||||
```
|
||||
|
||||
{{% notice info %}}
|
||||
If you close your shell or open a new shell, you'll need to re-enter `conda activate edukit` to reactivate the virtual environment and run ESP-IDF's `export.sh` (macOS/Linux) or `export.bat` (Windows) to re-add the ESP-IDF tools to your path each time.
|
||||
{{% /notice %}}
|
||||
|
||||
With the device successfully registered and provisioned in AWS IoT, go back to the **Blinky-Hello-World** directory by entering:
|
||||
```bash
|
||||
cd ../..
|
||||
```
|
||||
|
||||
## Chapter Conclusion
|
||||
In this chapter, you used the secure element to create an AWS IoT [thing](https://docs.aws.amazon.com/iot/latest/developerguide/thing-registry.html), set up a permissions [policy](https://docs.aws.amazon.com/iot/latest/developerguide/thing-policy-variables.html) for your thing, and attached the device certificate to it. All of this was done without ever exposing the secret private key and removing a potential avenue for it to be compromised.
|
||||
|
||||
On to [**Connecting to AWS IoT Core**](connecting-to-aws.html).
|
||||
|
||||
---
|
||||
{{% button href="https://github.com/m5stack/Core2-for-AWS-IoT-EduKit/issues" icon="fas fa-bug" %}}Report bugs{{% /button %}} {{% button href="https://community.m5stack.com/category/41/core2-for-aws" icon="far fa-question-circle" %}}Community support{{% /button %}}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 58 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user