Starting point and tutorial for simple IoT project with Microcontroller and GSM

0

Hy there, I would have expected that this is a simple task but apparently it is not: we need to create a proof of concept for a very simple IoT device. It shall control 3 digital outputs and 3 digital inputs and is connected via GSM modem. The device needs to be updatable over the air. We purchased a STM32 based evalboard with BG96 (L496G-CELL02) and a 1nce data SIM. Also we created an AWS account and run some basic PC based examples. But now we are missing a good starting point for our hardware. All ST documentation seems to be outdated, AWS is a jungle. Individually compile FreeRTOS seems too low-level. Any hints about a good starting point? Sample code? Tutorial? Best regards Harald

asked a year ago692 views
2 Answers
0

Hi Harald. ST provide the X-CUBE-AWS package for some of their evaluation boards, but unfortunately not the one you have. X-CUBE-AWS is a reference integration of FreeRTOS and AWS IoT Core features on the supported boards.

I'm not aware of a reference integration for this board. Assuming I'm correct, then some software engineering will be required. I suggest the following approach:

  1. Use STM32CubeIDE to generate an example project, that includes the FreeRTOS kernel, for your board.
  2. Extend that example to add the coreMQTT, coreMqttAgent, Cellular Interface and backoffAlgorithm libraries to the project, and then get basic MQTT pubsub working with IoT Core. The MQTT Agent Demo tutorial is probably your best guide. I recommend you do it with the mutual authentication option. You can publish the state of the I/O, and potentially subscribe to a topic to receive any state change requests for the outputs.
  3. You may consider to also add the AWS IoT Device Shadow library to report the I/O state and/or to control the outputs.
  4. With the I/O handled, then you could look to add the AWS IoT Jobs and AWS IoT OTA libraries to build out OTA capability. The OTA library needs to be ported to your device using the Platform Abstraction Layer to integrate it with the underlying hardware and ST's drivers and bootloader. The OTA demo tutorial can guide you. You can also find a full OTA implementation in X-CUBE-AWS.

For reference, some (deprecated but still useful) OTA ports to other microcontrollers:

An OTA PAL implementation for POSIX: https://github.com/aws/aws-iot-device-sdk-embedded-C/blob/main/platform/posix/ota_pal/source/ota_pal_posix.c

Example implementation of the OTA OS interface for FreeRTOS: https://github.com/aws/ota-for-aws-iot-embedded-sdk/blob/main/source/portable/os/ota_os_freertos.c

(Non-embedded) C-SDK and FreeRTOS demos:

UPDATE: There's also this reference integration: https://github.com/FreeRTOS/iot-reference-stm32u5 for the STM32U5. This is what's in X-CUBE-AWS 3.0. It uses FreeRTOS LTS: https://github.com/FreeRTOS/iot-reference-stm32u5/tree/main/Middleware/FreeRTOS. And uses jobs and OTA: https://github.com/FreeRTOS/iot-reference-stm32u5/tree/main/Middleware/AWS. OTA PAL here: https://github.com/FreeRTOS/iot-reference-stm32u5/tree/main/Projects/b_u585i_iot02a_ntz/Src/ota_pal.

profile pictureAWS
EXPERT
Greg_B
answered a year ago
-1

Here are a few suggestions:

  1. AWS IoT Device SDK: The AWS IoT Device SDK provides libraries in multiple programming languages to help you connect your devices to AWS IoT Core. It includes a library for C that can run on your STM32 evalboard with BG96. You can find the SDK and documentation at https://docs.aws.amazon.com/iot/latest/developerguide/sdk-c.html.
  2. AWS IoT Device Defender: AWS IoT Device Defender is a service that helps you secure your IoT fleet by continuously auditing security policies and detecting anomalies. It can also help with OTA updates. You can find more information and tutorials at https://aws.amazon.com/iot-device-defender/.
  3. AWS Greengrass: AWS Greengrass is a service that extends AWS to your devices, allowing you to run AWS Lambda functions locally on your devices. It includes OTA updates and is compatible with STM32 devices. You can find more information and tutorials at https://aws.amazon.com/greengrass/.
  4. AWS IoT 1-Click: AWS IoT 1-Click is a service that simplifies the process of triggering AWS Lambda functions from simple IoT devices like buttons or sensors. You can find more information and tutorials at https://aws.amazon.com/iot-1-click/.
  5. AWS IoT Analytics: AWS IoT Analytics is a service that provides advanced analytics for IoT data. It can help you process and analyze data from your devices, including OTA updates. You can find more information and tutorials at https://aws.amazon.com/iot-analytics/.

In terms of sample code and tutorials, the AWS documentation provides many examples and step-by-step guides. You can also find tutorials and code samples on GitHub and other developer communities.

hash
answered a year ago
  • This answer has a lot of incorrect information.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions