TinyML and edge AI on microcontrollers
How to fit a trained model onto a microcontroller (memory limits, integer quantisation, optimised kernels, which runtime suits which chip) and how to measure latency, energy and accuracy on the board.
Overview
TinyML means running a trained machine-learning model on a microcontroller, next to the sensor, instead of sending raw data to a server. A vibration monitor that reports “bearing wear likely” once an hour sends far less data than one that streams raw acceleration. It also keeps working when the network does not. This hub is for makers who want a keyword spotter or gesture classifier on a devkit and for product teams deciding whether on-device inference is worth the flash, RAM and engineering time.
The hub covers deployment: getting a model onto a chip, making it fit and fast, and measuring it honestly. It does not teach how networks are designed or trained. For that, our sister site the AI/ML Field Guide covers model theory, training and quantisation from the machine-learning side.
Key ideas
Memory sets the limits
A microcontroller model has two memory costs. The weights live in flash. The activations, the intermediate results between layers, live in RAM. The MLPerf Tiny paper’s reference models show the range: a DS-CNN (depthwise separable convolutional network) keyword spotter of 52.5 KB, a ResNet image classifier of 96 KB, an autoencoder for anomaly detection of 270 KB and a MobileNetV1 person detector of 325 KB. The runtime adds its own cost. Google states that the core of LiteRT for Microcontrollers “just fits in 16 KB on an Arm Cortex M3”, and that it needs no operating system, no standard C or C++ libraries and no dynamic memory allocation. Instead, the application hands the interpreter one fixed-size block of RAM, the tensor arena, and every buffer comes from there. In the original TensorFlow Lite Micro paper, the person-detection reference model used 81.79 kB of memory in total on a SparkFun Edge board.
Quantise to integers
Float32 weights take four bytes each. Full-integer quantisation converts weights and activations to 8-bit integers. Google’s table lists it as 4x smaller with a 3x or greater speed-up, and as the option for microcontrollers. It needs a representative dataset, roughly 100 to 500 real samples, so the converter can measure the range of each activation. Use real sensor data from your own board here, not a tidy public dataset.
The tooling moved in 2026. Google’s post-training quantisation page now says that quantisation during conversion is deprecated. The recommended path is to convert to a float32 model, then quantise with LiteRT Quantizer (formerly AI Edge Quantizer). Its integer-only recipe for microcontrollers is static_wi8_ai8. The migration guide was last updated on 13 October 2026, so older tutorials that set quantisation flags on the converter will drift out of date.
Kernels decide the speed
The runtime walks the model’s graph and calls a kernel for each operation. The interpreter itself costs little: in the TFLM paper it was under 0.1% of run time for the person-detection model on an Ambiq Apollo3 (Arm Cortex-M4) and about 3% to 4% for a very small hotword model. The kernels matter much more. Swapping reference kernels for Arm’s CMSIS-NN gave more than a 4x speed-up on the person detector, but only 25% on the hotword model, because less of its time went to the inner loops. CMSIS-NN has plain C, DSP-extension and Helium (M-profile Vector Extension) paths, supports int8 and int16, and its README states that it is bit-exact with the TFLM reference kernels.
Pick the runtime that matches the chip
LiteRT for Microcontrollers is the general option. Its GitHub repository still carries the name TensorFlow Lite for Microcontrollers (TFLM), while Google’s documentation uses the new name, so expect both in searches. It is C++17, needs a 32-bit platform, supports a subset of operations and cannot train on the device. Arm Cortex-M, Cadence Xtensa and Qualcomm Hexagon are tier-1 platforms tested in its CI, and Espressif ESP32 is listed as a community platform.
Espressif’s own ESP-DL targets the ESP32-S3 and ESP32-P4 (the original ESP32 runs its operators in plain C and is significantly slower). It uses its own FlatBuffers-based .espdl format, produced by the ESP-PPQ quantiser from ONNX or PyTorch models, and needs ESP-IDF release/v5.3 or later. Edge Impulse is a hosted service whose deployment step produces a C++ library with no external dependencies. It estimates latency, flash and RAM for the chosen target, and the company says its EON Compiler uses less RAM and flash than TFLite.
Measure on the board, the way MLPerf Tiny does
Vendor speed figures use their own models and clocks. MLPerf Inference: Tiny from MLCommons gives a common yardstick: keyword spotting, visual wake words, image classification, anomaly detection and streaming wakeword, each with a minimum accuracy, with v1.4 the latest published round. Its paper describes the method. Latency is the median of five runs, each at least 10 seconds and 10 inferences. Energy is reported in microjoules per inference, measuring only the power delivered to the device’s core, with the level shifters on a separate channel and excluded. Copy that discipline even for an informal test: fixed clock, fixed supply voltage, the radio state stated, and accuracy checked on the board with the quantised model, not on the laptop.
For makers
Start with a hosted flow such as Edge Impulse or a LiteRT for Microcontrollers example on a supported board. Record your own sensor data from the start. Check the quantised model’s accuracy on the board before you build anything around it.
For product teams
Budget flash for weights and RAM for the tensor arena before choosing the chip. Quantise with real field data, pin the quantiser version (the LiteRT tooling changed in 2026), and keep the float model to re-quantise. Report latency and energy per inference with clock, voltage and radio state, following the MLPerf Tiny method. Treat a model update as a firmware update, with OTA, signing and rollback.
Where to start
Get a toolchain working with /learn/beginner/03-toolchains-and-first-flash/, then read a real sensor with /learn/beginner/05-sensors-over-i2c/, because a model is only as good as the data you capture. /learn/beginner/08-power-and-sleep/ and the current measurement method show how to measure energy. For chip choice see /topics/microcontrollers-and-socs/. For ESP-DL, the ESP32-S3-DevKitC-1 and ESP32-P4-Function-EV-Board match its supported chips. Model updates follow /topics/ota-and-fleet-management/.
Tools and platforms
As of 28 November 2026, from each project’s own documentation.
| Job | Tool | What it gives you | Source |
|---|---|---|---|
| Portable inference on 32-bit MCUs | LiteRT for Microcontrollers (TFLM) | Interpreter with fixed arena, 16 KB core on Cortex-M3, Apache-2.0 | Google AI Edge, GitHub |
| Integer quantisation for LiteRT | LiteRT Quantizer | static_wi8_ai8 integer-only recipe with calibration data |
Migration guide |
| Fast kernels on Arm Cortex-M | CMSIS-NN | C, DSP and Helium paths, int8 and int16, bit-exact with TFLM | Arm CMSIS-NN |
| Inference on ESP32-S3 or ESP32-P4 | ESP-DL with ESP-PPQ | .espdl models from ONNX or PyTorch, 8-bit, 16-bit or mixed |
ESP-DL guide |
| Hosted flow to a deployable library | Edge Impulse | C++ library, int8 or float32 builds, latency, RAM and flash estimates | Edge Impulse |
| Comparing boards fairly | MLPerf Inference: Tiny | Five tasks with accuracy targets, latency and energy rules | MLCommons |
Common mistakes
- Training on a public dataset and deploying next to a sensor with a different noise, gain and sample rate.
- Calibrating quantisation with a handful of samples, or with data that misses the edge cases.
- Checking accuracy with the float model on the host and never with the int8 model on the board.
- Sizing the tensor arena by guesswork, then losing RAM the radio stack needed.
- Timing only the inference and forgetting pre-processing, which can dominate for audio and vibration.
- Quoting speed without the clock, voltage and kernel library used.
Going deeper
- Google AI Edge, LiteRT for Microcontrollers and the LiteRT Quantizer migration guide.
- R. David et al., TensorFlow Lite Micro: Embedded Machine Learning on TinyML Systems, arXiv v3, 2021, for the interpreter and arena design.
- C. Banbury et al., MLPerf Tiny Benchmark, arXiv v4, 2021, for the measurement method.
- Arm, CMSIS-NN.
- Espressif, ESP-DL User Guide.