Build and run a letter recognition NN model on an STM32L4 Discovery board
Introduction
Prepare development environment
Collect training data
Train the model
Feature extraction
Run the model on development board
Next Steps
Build and run a letter recognition NN model on an STM32L4 Discovery board
Who is this for?
This is an advanced topic for software developers interested in building network models for microcontrollers.
What will you learn?
Upon completion of this Learning Path, you will be able to:
- Build a letter recognition neural network(NN) model using TensorFlow framework
- Run the NN model on an STM32 B-L475E-IOT01A2 board using STM32CubeAI
Prerequisites
Before starting, you will need the following:
- Familiarity with ML concepts
- Familiarity with C programming on microcontrollers
- STM32 B-L475E-IOT01A2 board
Summary
This summary was drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
You’ll build a TensorFlow model that recognizes letters from motion data on an STM32 B-L475E-IOT01A2. First, you’ll use Anaconda and a Jupyter notebook to collect accelerometer samples and train a multilayer perceptron. Then, you’ll extract statistical features, retrain the model, import it with STM32Cube.AI, and run predictions with the board’s onboard accelerometer.
Frequently asked questions
These FAQs were drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
Jupyter shows
In[*] while a cell is running. When complete, it changes to In[N], where N is the execution count.You’ll collect accelerometer data from the STM32 board and save it as CSV files. The notebook discovers these CSV files from the
samples_dir location and loads them for training.The example model uses an input shape of (3, stride), representing three accelerometer axes over a time window. Labels are one-hot encoded using
tf.keras.utils.to_categorical with the class count derived from the unique labels.The process computes the mean and standard deviation for each accelerometer axis and saves these as features. You then train a model on these feature vectors instead of the raw time-series samples.
Use the Board Selector to choose the B-L475E-IOT01A board, then set the project name and location in Project Manager. Import the trained model using STM32Cube.AI within STM32CubeMX, and continue with Pinout & Configuration.