Skip to content

D-Coder-42/Edge-AIoT

Repository files navigation

Edge AIoT Workshop Projects - B-L4S5I-IOT01A

This repository contains all the source code and projects developed during the Edge AIoT workshop. The primary hardware used was the STMicroelectronics B-L4S5I-IOT01A Discovery Kit, focusing on sensor interfacing, embedded machine learning (Edge AI), and Internet of Things (IoT) connectivity.

Hardware and Software Stack

Hardware

  • Development Board: STMicroelectronics B-L4S5I-IOT01A
  • Onboard Sensors:
    • HTS221: Capacitive digital sensor for relative humidity and temperature.
  • External Sensors Interfaced:
    • BH1750: Ambient Light Sensor (I2C)
    • HTU21D: Temperature & Humidity Sensor (I2C)
    • MPU6050: 6-axis Gyroscope and Accelerometer (I2C)

Software & Tools

  • IDE: STM32CubeIDE
  • AI/ML Tools:
    • NanoEdge AI Studio: For generating on-device classification and anomaly detection models.
    • Google Colab: For training custom TensorFlow/Keras models.
    • X-CUBE-AI: STM32Cube Expansion Pack for converting pre-trained neural networks into optimized C code.
  • IoT Platforms:
    • Adafruit IO: Cloud platform for data logging, visualization, and MQTT communication.
    • Node-RED: Flow based programming for event-driven applications and creating IoT flows.

Project Directory

This repository is structured into folders, each corresponding to a specific module or project from the workshop.

Folder Name Description
blinkLED Basic GPIO operations. Interfaced with the onboard user LED and used interrupts to read the state of the USER push-button.
BH1750_I2C Code to interface with the BH1750 ambient light sensor and read lux values and deploy anomaly detection model generated using NanoEdge AI Studio.
HTS221_inbuiltI2C Reading temperature and humidity from the onboard HTS221 sensor.
HTU21D_I2C Reading temperature and humidity from an external HTU21D sensor module.
MPU6050_I2C Interfacing with the MPU6050 to get raw accelerometer and gyroscope data.
WiFi_SPI Using the onboard WiFi chip to connect to a network and publish sensor data to an Adafruit IO feed using the MQTT protocol.
Motion Classifier Contains the Python code, dataset, and trained model files for motion classification.
MPU6050_Motion_Classification On-board C implementation of the motion classification model, converted from the Python model using X-CUBE-AI.

Communication Protocols

The following communication protocols were used to interface with peripherals and sensors:

  • UART (Universal Asynchronous Receiver-Transmitter): Used for sending debug messages and sensor data from the board to a PC via the ST-Link's Virtual COM Port.
  • I2C (Inter-Integrated Circuit): The primary protocol for communicating with the onboard HTS221 sensor and external sensors like the MPU6050, BH1750, and HTU21D.
  • SPI (Serial Peripheral Interface): Used to communicate with the onboard Inventek ISM43362-M3G-L44 WiFi module for IoT connectivity.

Edge AI & IoT Integration Workflow

Two primary workflows were explored for deploying machine learning models on the microcontroller:

  1. Automated Anomaly Detection (NanoEdge AI Studio):

    • Collected normal and abnormal light intensity (lux) data from the BH1750 sensor.
    • Used NanoEdge AI Studio to find the optimal ML library for the collected data.
    • Generated a static C library for Anomaly Detection.
    • Integrated the generated library into an STM32CubeIDE project to detect unusual lighting conditions in real-time.
  2. Custom Neural Network (TensorFlow & X-CUBE-AI):

    • Captured a dataset of different motions (e.g., stationary, walking) using the MPU6050.
    • Designed and trained a TensorFlow/Keras neural network in a Google Colab environment (Python code found in the Motion Classifier folder).
    • Used the X-CUBE-AI tool to convert the trained model (.h5 format) into optimized C-code.
    • The generated C-code was then integrated into the MPU6050_Motion_Classification project to perform real-time motion classification on the board.

For the IoT part, the board's WiFi module was used to connect to Adafruit IO and publish real-time sensor readings. This data was then visualized on an Adafruit IO dashboard and could be used to trigger alerts via Node-RED.

About

All codes written for Edge AIoT Workshop for STM32L4R5VIT6

Topics

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Contributors

Languages