Skip to content

This project performs motion classification using accelerometer data (accX, accY, accZ) on an STM32 board. The AI model is built using NanoEdge AI Studio, and sensor data is collected via a USB serial emulator for training and testing. It demonstrates how embedded AI can detect different movements (like tilt, shake, or rest) directly on the device

Notifications You must be signed in to change notification settings

kartikvd24/Flight_contoller_stm32_mpu6050

Repository files navigation

🧠 Edge AI Motion Classification using NanoEdge AI Studio

This project demonstrates motion classification using 3-axis accelerometer data (accX, accY, accZ) on an STM32 board.
The model is built and tested using NanoEdge AI Studio, and sensor data is collected via USB Serial Emulator for training and validation.


⚙️ Project Overview

  • Goal: Classify different motion types (e.g., rest, shake, tilt) using acceleration data.
  • Hardware Used: STM32 Nucleo Board (or compatible)
  • Software Used:

🧩 Step 1: NanoEdge AI Studio Setup

  1. Open NanoEdge AI Studio and create a new project.
  2. Select:
    • Sensor Type: Accelerometer
    • Data Input: accX, accY, accZ
    • Target: STM32F401RE
  3. Go to the Signals part and create new classes for the reuired entities for each class use "log from usb serial" and collect different singnals upto 500 signals i.e more the signals more the accuracy.
  4. then go to benchmark section and create new bench mark and use all the signals for traning.
  5. Then go for validation, in that use the best model that has been generated and use serial emulator just for testing after testing Deployment can be directly done using the generated code and dumping it directly on to the hardware. . Choose Classification as the AI function.
    . Configure sampling frequency (e.g., 50 Hz) and window size (e.g., 128 samples).
    . Import or record data from the serial emulator connected to STM32.

📘 NanoEdge AI Studio Interface: NanoEdge AI Studio

image image image

🧮 Step 2: USB Serial Data Logging

image This is done in the cubeide's terminal itself but you can use realterm for easier approach

To collect data, connect the STM32 via USB. The accelerometer values are sent using the serial port.

Example Output:


🧰 Step 3: Serial Emulator Setup (Tera Term)

  1. Connect STM32 via USB and open Tera Term.
  2. Select the correct COM Port.
  3. Set Baud Rate to 115200, Data bits: 8, Parity: None, Stop bits: 1.

📈 Step 4: Data Collection & Import into NanoEdge

  • Use Tera Term’s logging feature to save accelerometer data as .csv.
  • Import the file into NanoEdge AI Studio for model training.
  • Label datasets for each motion class (e.g., still, tilt, shake).

📘 Data Import Interface: ![Data Import]image


🧠 Step 5: Model Training & Testing

  • NanoEdge AI Studio automatically tests multiple ML algorithms.
  • Select the best performing model based on accuracy and RAM/ROM usage.
  • Export the generated .lib file and integrate into STM32CubeIDE.

🧾 Step 6: Deploy and Test

  • Include the generated NanoEdge AI Library in your project.
  • Stream new live accelerometer data over serial and view classification results in real-time.

✅ Results

Motion Predicted Class Confidence
Rest Stable 98%
left Tilt left Tilt Detected 95%
flip flip Detected 97%
right Tlit Right Tilt Detected 97%
up ascending 100%
down decsending 97%

🧩 Conclusion

This project demonstrates how to use NanoEdge AI Studio and serial data logging for edge AI motion classification.
Using accX, accY, and accZ, we trained and tested an embedded AI model capable of classifying human or device motion in real time — without needing cloud computing.


📚 References

Also there is a video attached in the files you can go through the working of the project.

About

This project performs motion classification using accelerometer data (accX, accY, accZ) on an STM32 board. The AI model is built using NanoEdge AI Studio, and sensor data is collected via a USB serial emulator for training and testing. It demonstrates how embedded AI can detect different movements (like tilt, shake, or rest) directly on the device

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages