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.
- Goal: Classify different motion types (e.g., rest, shake, tilt) using acceleration data.
- Hardware Used: STM32 Nucleo Board (or compatible)
- Software Used:
- NanoEdge AI Studio
- STM32CubeIDE
- Tera Term
- Serial Emulator for testing (Virtual COM port)
- Open NanoEdge AI Studio and create a new project.
- Select:
- Sensor Type: Accelerometer
- Data Input: accX, accY, accZ
- Target: STM32F401RE
- 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.
- then go to benchmark section and create new bench mark and use all the signals for traning.
- 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:
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.
- Connect STM32 via USB and open Tera Term.
- Select the correct COM Port.
- Set Baud Rate to 115200, Data bits: 8, Parity: None, Stop bits: 1.
- 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]
- NanoEdge AI Studio automatically tests multiple ML algorithms.
- Select the best performing model based on accuracy and RAM/ROM usage.
- Export the generated
.libfile and integrate into STM32CubeIDE.
- Include the generated NanoEdge AI Library in your project.
- Stream new live accelerometer data over serial and view classification results in real-time.
| 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% |
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.
Also there is a video attached in the files you can go through the working of the project.
