In this chapter you’ll configure, build, and flash your device firmware—which will allow your device to connect to your Wi-Fi network and 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 IoT endpoint. Establishing a secure MQTT connection is simplified with the AWS IoT Device SDK for Embedded C and the pre-provisioned secure hardware certificates in the on-board Microchip ATECC608 Trust&GO. With the secure element, you do not need to retrieve certificates from AWS IoT Core, or generate your own, to connect. The connectivity libraries in the AWS IoT Device SDK for Embedded C simplify connectivity and access to AWS IoT services and features.
Configuration of your source code is handled through Kconfig. 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.
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.
Go to the configuration menu from the Blink-Hello-World directory of the repository and enter:
pio run --environment core2foraws --target 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.
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.
You are now ready to build (compile) and upload the Blinky Hello World firmware. The process is the same as with the Getting Started tutorial for building, flashing, and monitoring the serial output:
pio run --environment core2foraws
pio run --environment core2foraws --target upload
pio run --environment core2foraws --target monitor
If during upload or while monitoring the serial output you receive an error about an incorrect port or timeout, open the
platformio.ini file, and follow the instructions there to manually set the upload port.
In this chapter, you have successfully compiled and flashed 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.