Skip to content
cd ../blog

Fitting a 1.1 KB model onto an STM32

For bearing fault detection, five models performed almost identically. The choice came down not to accuracy but to the microcontroller's memory: 289 parameters, ~1.1 KB in float32.

2 min read

The goal

My capstone project, Predictive-Edge, aims to detect bearing faults in industrial motors early and estimate their remaining useful life (RUL) — and to do it not in the cloud, but on the microcontroller sitting next to the motor.

The features come from physics

Instead of feeding raw vibration straight into the model, I extracted physics-based features. An FFT is taken of the 1 kHz vibration signal, and 8 features, including harmonic ratio, spectral entropy, RMS, and peak-to-peak value, are computed around the bearing's outer-race fault frequency (BPFO, 100 Hz in this setup) and its harmonics. Temperature and current are fed into the model as well.

Good features make a small model's job easier — and on an embedded target, that means everything.

Five models, nearly the same score

I compared Logistic Regression, Random Forest, SVM, Gradient Boosting, and MLP. All of them landed around F1 ≈ 0.99. With accuracy no longer a differentiator, memory and inference cost decided the choice.

Methodology

  • GridSearchCV and 5-fold cross-validation.
  • The scaler sits inside the Pipeline — so no information from the training data leaks into the validation folds.
  • For the MLP, the difference between (32, 16) and (16, 8) was within one standard deviation; I chose (16, 8), which is 3× smaller.

By the numbers

MetricValue
Parameters289
Model size (float32)~1.1 KB
With int8 quantization289 B
TargetSTM32H7 (2 MB Flash)

There's also a monitoring side: a Flask REST API and Chart.js show the health status and remaining useful life of a 200-motor fleet in a single dashboard.

An honest limitation

The dataset is synthetic, generated from a physical fault model. Running the model on an actual STM32 board and validating it with real sensor data is in progress. The 0.99 F1 score should be read in that context.