Machine learning is no longer limited to cloud servers, GPUs, and high-performance computers.
Small microcontrollers can now run useful AI models directly inside sensors, appliances, industrial equipment, wearables, robots, and battery-powered devices.
This approach is known as TinyML.
TinyML brings machine learning to highly resource-constrained embedded systems. Instead of sending raw data to a remote server, the microcontroller can process sensor information locally and make a decision in real time.
Typical applications include:
- vibration anomaly detection,
- keyword spotting,
- gesture recognition,
- machine-condition classification,
- smart sensor intelligence.
Fundamentals and Technology Overview
What Is TinyML?
TinyML is the deployment of small machine-learning models on devices with limited:
- Flash,
- SRAM,
- CPU performance,
- energy budget.
The model is normally trained on a workstation or cloud platform and then deployed to the microcontroller for inference.
TinyML is therefore a specialized subset of embedded AI.
TinyML vs Embedded AI
Embedded AI spans a wide range of hardware, including:
- MCUs,
- MPUs,
- DSPs,
- NPUs,
- embedded GPUs.
TinyML focuses specifically on the smallest end of this spectrum: microcontrollers and smart sensors.
TinyML vs Cloud AI
Cloud AI sends sensor data to remote servers.
TinyML processes the data locally.
This provides:
- lower latency,
- lower bandwidth usage,
- improved privacy,
- offline operation,
- lower communication energy.
Typical TinyML Architecture
A TinyML device often follows this pipeline:
Sensor → Data Acquisition → Preprocessing → Feature Extraction → Model Inference → Decision → Action
Each stage must fit within strict MCU constraints.
Sensors Used in TinyML
Common sensors include:
- accelerometers,
- microphones,
- current sensors,
- temperature sensors,
- IMUs,
- pressure sensors,
- low-resolution cameras.
Data Acquisition
The MCU may collect sensor data using:
- ADC,
- I2C,
- SPI,
- I2S,
- camera interfaces.
DMA is often useful for transferring samples into RAM without consuming excessive CPU time.
Preprocessing
Raw data frequently requires preprocessing.
Typical operations include:
- filtering,
- normalization,
- windowing,
- resampling.
Good preprocessing can significantly reduce model complexity.
Feature Extraction
Many TinyML systems do not feed raw sensor values directly into a neural network.
Instead they calculate compact features such as:
- RMS,
- FFT coefficients,
- spectral peaks,
- MFCC audio features,
- statistical values.
This can reduce memory and computational requirements.
TinyML Microcontroller Constraints
The main challenge is that microcontrollers have much less memory and computing power than desktop systems.
A typical MCU may provide:
- hundreds of kilobytes of Flash,
- tens or hundreds of kilobytes of SRAM.
Flash Memory
Flash stores:
- firmware,
- model weights,
- constant data.
The model must fit alongside the normal embedded application.
SRAM
SRAM is often the harder constraint.
Inference requires memory for:
- activation tensors,
- temporary buffers,
- sensor buffers,
- feature extraction.
A model can fit in Flash but still fail because the tensor arena is too large for SRAM.
CPU Performance
Even a small network may require millions of arithmetic operations.
The MCU must finish inference before the application deadline.
Performance, Memory, and Data Processing
Power
Battery products may spend most of their life asleep.
Inference must therefore be:
- infrequent,
- fast,
- energy efficient.
Model Optimization for TinyML
TinyML depends heavily on model optimization.
The most common techniques are:
- quantization,
- pruning,
- smaller network architectures,
- feature engineering.
Quantization
Quantization reduces numerical precision.
A common conversion is:
32-bit floating point → 8-bit integer
Benefits include:
- smaller model,
- lower RAM usage,
- faster execution,
- lower energy consumption.
INT8 Inference
INT8 is especially important because many MCU libraries and AI accelerators are optimized for integer arithmetic.
Post-Training Quantization
A floating-point model can be quantized after training.
This is easy to implement but may reduce accuracy.
Quantization-Aware Training
Quantization can also be simulated during training.
This often preserves accuracy better.
Pruning
Pruning removes weights that contribute little to the model.
It can reduce model size, although the real speed improvement depends on runtime support for sparse computation.
Compact Neural Networks
TinyML commonly uses compact models such as:
- small CNNs,
- fully connected networks,
- depthwise separable convolutions.
The goal is to achieve acceptable accuracy with minimal operations.
LiteRT Micro / TensorFlow Lite Micro
A major runtime for microcontroller AI has historically been TensorFlow Lite for Microcontrollers.
Google's current LiteRT naming extends the on-device runtime family, while the microcontroller ecosystem continues through LiteRT/TensorFlow Lite Micro-compatible components.
NXP's current eIQ implementation describes TensorFlow Lite Micro as optimized for:
- resource-constrained devices,
- Cortex-M processors,
- smaller binary size,
- lower inference latency. citeturn255706search1turn255706search2
Static Memory Allocation
Microcontroller inference runtimes commonly avoid dynamic allocation.
A fixed memory arena is reserved for:
- tensors,
- intermediate activations,
- runtime buffers.
This improves predictability.
Bare-Metal and RTOS Operation
TinyML can run:
- bare metal,
- FreeRTOS,
- other small RTOS environments.
A full Linux OS is not required.
Arm CMSIS-NN
CMSIS-NN provides optimized neural-network kernels for Cortex-M processors.
It accelerates operations such as:
- convolution,
- fully connected layers,
- activation functions.
Arm's current LiteRT CMSIS Pack supports three execution options:
- software reference,
- CMSIS-NN,
- Ethos-U NPU acceleration. citeturn255706search4turn255706search6
Implementation, Testing, and Optimization
Why CMSIS-NN Matters
Generic C implementations may be too slow.
CMSIS-NN uses Cortex-M architecture features more efficiently, improving:
- inference latency,
- energy efficiency.
DSP Instructions
Many Cortex-M processors include DSP instructions.
These accelerate:
- multiply-accumulate,
- vector arithmetic,
- signal processing.
This benefits both:
- feature extraction,
- neural inference.
NPU-Enabled Microcontrollers
Newer embedded processors increasingly include small neural-processing units.
An NPU can run inference while the CPU handles:
- sensor control,
- communication,
- application logic.
This creates a heterogeneous architecture even inside an MCU-class system.
TinyML Development Workflow
Step 1: Define the Problem
Choose a narrow use case such as:
- bearing anomaly detection,
- keyword recognition,
- gesture classification.
Step 2: Collect Representative Data
Data should include real operating variation.
For industrial applications, collect across:
- temperature,
- machine speed,
- load,
- mounting differences.
Step 3: Label the Data
Supervised learning requires accurate labels.
Poor labels directly reduce model quality.
Step 4: Preprocess and Extract Features
Use only preprocessing that can also run on the target MCU.
Step 5: Train the Model
Training generally occurs on:
- workstation,
- GPU,
- cloud platform.
Step 6: Evaluate Accuracy
Measure:
- precision,
- recall,
- confusion matrix,
- false-positive rate.
Step 7: Quantize
Convert the model to an MCU-friendly representation such as INT8.
Step 8: Integrate the Runtime
Typical choices include:
- LiteRT/TensorFlow Lite Micro,
- NXP eIQ,
- ST Edge AI tools.
Step 9: Benchmark on Real Hardware
Measure:
- Flash,
- SRAM,
- inference latency,
- energy.
Step 10: Validate in Real Conditions
Test the final system with real:
- noise,
- temperature,
- mechanical variation.
NXP eIQ
NXP's eIQ environment supports AI deployment across MCUs and application processors.
Its TensorFlow Lite Micro runtime targets resource-constrained i.MX RT crossover MCUs and is delivered through the MCUXpresso SDK. citeturn255706search1turn255706search3
NXP also supports different execution engines across:
- Cortex-M,
- Cortex-A,
- GPUs,
- NPUs. citeturn255706search0
ST Edge AI
ST provides Edge AI software for deploying models on:
- STM32 MCUs,
- STM32 MPUs,
- smart sensors.
ST's current tools support both:
- bring your own data,
- bring your own model
workflows and focus on running inference locally instead of relying on the cloud. citeturn255706search7
TinyML Memory Planning
Memory should be estimated before selecting hardware.
A practical budget includes:
- model weights,
- tensor arena,
- input buffer,
- feature buffer,
- RTOS stacks,
- normal firmware variables.
Example
Suppose an MCU provides:
- 512 KB Flash,
- 128 KB SRAM.
A realistic allocation may be:
Firmware
150 KB Flash.
Model
100 KB Flash.
Tensor Arena
60 KB SRAM.
Sensor Buffer
20 KB SRAM.
RTOS / Stacks / Variables
30 KB SRAM.
That leaves little safety margin.
SRAM Often Limits the Design First
This is why model selection should consider:
- peak activation memory,
- not only model file size.
TinyML Latency
Inference latency must match the use case.
Examples:
Vibration Monitoring
Tens of milliseconds may be acceptable.
Gesture Detection
Around 100 ms may still feel responsive.
Motor Protection
Primary protection should remain deterministic and should not depend solely on AI inference.
TinyML and Real-Time Control
TinyML is often best used alongside conventional embedded logic.
Example:
TinyML
Predicts bearing degradation.
Deterministic Safety Logic
Trips the machine during overcurrent.
This provides intelligence without weakening hard safety mechanisms.
Power Optimization
Common strategies include:
- deep sleep,
- event-triggered inference,
- DSP acceleration,
- NPU acceleration,
- lower sensor duty cycle.
Duty-Cycled TinyML
A battery sensor may:
- sleep,
- wake periodically,
- sample,
- run inference,
- transmit only if necessary,
- sleep again.
This can support long battery life.
Processing Resources and Performance Tradeoffs
Keyword Spotting
Keyword spotting is one of the classic TinyML examples.
A typical pipeline is:
- microphone,
- audio frame buffer,
- MFCC features,
- small neural network,
- command classification.
Industrial Vibration Monitoring
A vibration node may use:
- accelerometer,
- DMA buffer,
- FFT or statistical features,
- model inference,
- anomaly score,
- maintenance alert.
This can run directly on a Cortex-M-class MCU.
Motor Current Analysis
TinyML can analyze motor-current signatures to identify patterns associated with:
- overload,
- mechanical imbalance,
- abnormal operating state.
This can add intelligence without adding another sensor.
Gesture Recognition
An IMU can provide:
- acceleration,
- angular velocity.
A compact model can classify gestures locally.
Smart Sensors
Instead of transmitting raw data, a smart sensor can send:
- class label,
- probability,
- anomaly score.
This dramatically reduces network traffic.
Privacy
Local inference means raw audio, motion, or sensor data does not necessarily need to leave the device.
This is useful in:
- wearables,
- microphones,
- industrial monitoring.
Bandwidth Reduction
TinyML can transform thousands of raw samples into one useful decision.
This is especially valuable on:
- LoRaWAN,
- cellular IoT,
- low-bandwidth field networks.
Model Updates
Models may need updates as:
- equipment ages,
- process conditions change,
- more data becomes available.
Treat model updates like firmware updates with:
- authentication,
- rollback protection.
Dataset Drift
A model may become less accurate after deployment.
Monitor:
- false positives,
- false negatives,
- confidence distributions.
Common TinyML Mistakes
Starting With Too Large a Model
Start with the smallest model that solves the problem.
Ignoring SRAM
Model weights are only part of the memory requirement.
Training Only on Clean Lab Data
Real industrial sensors contain noise and environmental variation.
Technology Comparison and Selection
Evaluating Only Accuracy
Also measure:
- latency,
- RAM,
- power,
- false alarms.
Choosing Hardware Before Benchmarking
Run the real model on representative hardware.
No Fallback Behavior
Define what happens when confidence is low.
Performance Optimization Options
Useful techniques include:
- INT8 quantization,
- CMSIS-NN,
- DSP optimization,
- NPU acceleration,
- better feature extraction.
Measuring Inference Time
Measure from:
input data ready
to:
prediction available.
Include preprocessing if it belongs to the real decision path.
Measuring Power
Measure energy for:
- sensor acquisition,
- preprocessing,
- inference,
- radio communication.
The AI model may not be the largest power consumer.
TinyML Hardware Selection
Important parameters include:
- Flash size,
- SRAM size,
- CPU architecture,
- DSP extensions,
- NPU support,
- sensor interfaces,
- software ecosystem,
- power modes.
Selection Table
| Workload | Typical Hardware |
|---|---|
| Simple anomaly detection | Low-/mid-range MCU |
| Keyword spotting | DSP-capable Cortex-M |
| Gesture recognition | Cortex-M + IMU |
| Vibration classification | Cortex-M4/M7/M33 |
| Simple vision | High-end MCU / NPU MCU |
| Complex multi-camera vision | MPU / NPU / GPU |
TinyML vs NPU-Based Edge AI
TinyML can run entirely on a CPU.
NPU-enabled MCUs can execute larger or more frequent models at lower energy.
The boundary between TinyML and larger embedded AI continues to move as microcontrollers add:
- more SRAM,
- vector instructions,
- dedicated AI accelerators.
Software Ecosystem Matters
A powerful MCU is useful only if the model can be deployed efficiently.
Check:
- supported operators,
- compiler support,
- runtime,
- debugging tools,
- vendor libraries.
Future of TinyML
TinyML will continue expanding as microcontrollers gain:
- stronger DSP,
- vector extensions,
- NPUs,
- larger memories.
Model architectures are also becoming more compact.
TinyML and Physical AI
TinyML enables intelligence close to sensors and actuators.
A smart actuator can:
- sense,
- classify,
- react locally.
This creates a distributed intelligence layer underneath larger robot or factory AI systems.
Conclusion
TinyML brings machine learning into microcontroller-class embedded systems.
It allows low-power devices to perform useful inference directly at the edge.
The central challenge is fitting the complete AI pipeline inside strict limits for:
- Flash,
- SRAM,
- CPU,
- energy.
Successful TinyML systems use:
- compact models,
- feature extraction,
- INT8 quantization,
- optimized runtimes,
- CMSIS-NN,
- DSP or NPU acceleration.
The most important engineering principle is:
optimize the complete sensor-to-decision pipeline, not only the neural network.
A small, well-designed model running on a modest MCU can often provide more practical value than a larger model that requires expensive hardware or continuous cloud connectivity.
For industrial applications, TinyML is especially promising for:
- predictive maintenance,
- condition monitoring,
- smart sensors,
- local classification.
As microcontrollers become more capable, machine learning will increasingly become a normal embedded-system feature.