Hopefully you enjoyed the journey of building your cloud connected blinky project. Using PlatformIO, you were able to configure, build, flash, and monitor your Core2 for AWS IoT EduKit’s firmware. Your device is now registered as an AWS IoT thing in your AWS account for secure cloud connectivity using on-board secure hardware. 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.
While the AWS IoT EduKit program does not teach C or require it, it is critical for embedded development. The control and flexibility from the lower level code allows you to gain the maximum potential from your hardware. If you are not familiar with C programming but curious to learn or if you are a bit rusty and want dive into the application code we provide in this program, Jens Gustedt provides Modern C under the Creative Commons license and it is free to download.
The application on the device runs using the FreeRTOS kernel—a real-time operating system (RTOS). It is bundled into the binary you compiled (as well as other libraries and drivers) with your application code. The FreeRTOS kernel schedules a block of sequential code as a task to give it a share of processor run time. There are tasks that typically loop forever to create messages to be sent to AWS, process received messages, update the display, blink the LEDs, etc.
The Core2 for AWS IoT EduKit packs a 240MHz dual core processor, however, it pales in comparison to the 8+ core at 4+GHz computers common today. To make the most out of the precious processor time, the FreeRTOS kernel puts tasks in a states such as running or suspended. The FreeRTOS kernel gives microcontroller applications the ability to optimize the processor by rapidly switching between individual tasks. A task can run once another task has put itself into a suspended or blocked state (see diagram below). This gives the appearance of concurrency and greatly improves an embedded application’s performance when compared to a simpler super loop application.
While super loop applications are simpler to program, areas of code that block/delay execution of other code cause the MCU to sit idle. A device connecting to the AWS cloud will have variable round-trip latency and bandwidth constraints that make the performance advantage of using an RTOS necessary. An RTOS provides significant advantages for other applications where it’s paramount to not lose data or to be able to perform a critical operation without being obstructed by another code block’s execution (e.g. health and safety), or to simply drive a smooth display screen.
The AWS IoT Device SDK for Embedded C used in this example provided simplified connectivity and messaging to/from AWS IoT and was able to work with the included secure element library to make device authentication easy. The Device SDK for Embedded C is located in the
The device’s hardware features such as the screen, power management chip, secure element, speaker, microphone, 6-axis inertial measurement unit (IMU), touch driver, LED bar, and more are bundled as a board support package (BSP). The BSP are drivers with APIs that provides a simplified way to accessing the features of the hardware. The BSP is located in the
Core2-for-AWS-IoT-EduKit/Blink-Hello-World/components/core2foraws/ folder. In this example, the SK6812 driver was used to control the side LED bars and the LVGL library was used to show the elements on the display. To view the available application programming interfaces (APIs) of the BSP and their usage, see the Core2 for AWS IoT EduKit API reference.
On to the next tutorial, Smart Thermostat.