Machine learning is no longer confined to cloud servers and GPU clusters. Arduino TinyML (Tiny Machine Learning) brings AI inference directly onto microcontrollers — enabling gesture recognition, keyword spotting, anomaly detection, and predictive maintenance at the edge, with zero internet latency and without sending sensitive sensor data to the cloud. This guide covers the hardware requirements, frameworks, workflow, and practical projects for arduino tinyml machine learning that you can build today.
Table of Contents
- What Is TinyML and Why Does It Matter?
- Hardware Requirements for Arduino TinyML
- TinyML Frameworks: TFLite Micro vs Edge Impulse
- Edge Impulse Workflow End-to-End
- Project: Gesture Recognition with IMU
- Project: Keyword Spotting with Microphone
- Project: Anomaly Detection for Predictive Maintenance
- FAQ
What Is TinyML and Why Does It Matter?
TinyML is the practice of running trained machine learning models on microcontrollers and other resource-constrained edge devices — think devices with kilobytes of RAM, milliwatts of power consumption, and no operating system. Unlike cloud ML, where raw sensor data is uploaded for processing, TinyML performs inference locally on the device that collected the data.
The benefits are substantial:
- Latency: inference in milliseconds, no network round-trip
- Privacy: raw audio, images, and biometric data never leave the device
- Connectivity independence: operates offline or in spotty networks
- Power efficiency: process locally on a 5 mW MCU instead of keeping a WiFi link active
- Cost: no cloud compute bills per inference
TinyML is now used commercially in always-on keyword detection (“Hey Siri”), predictive maintenance sensors in factories, fall detection in wearables, and wildlife acoustic monitoring in remote locations. The Arduino ecosystem, especially the Nano 33 BLE Sense family, has become one of the primary platforms for learning and prototyping TinyML applications.
Hardware Requirements for Arduino TinyML
Not every Arduino board can run TinyML workloads. The requirements are:
- RAM: minimum 256 KB for most useful models. TensorFlow Lite Micro’s interpreter alone uses ~20–50 KB, and model weights and activation buffers need the rest.
- Flash: 512 KB minimum for a model + firmware. 1 MB+ recommended.
- Processing power: 32-bit ARM Cortex-M CPU at 48+ MHz. 8-bit AVR boards (Uno, Mega, Nano) do not meet this bar — they simply do not have enough RAM or compute speed.
Supported boards for Arduino TinyML:
| Board | MCU | RAM | Onboard Sensors |
|---|---|---|---|
| Nano 33 BLE Sense | nRF52840 @ 64 MHz | 256 KB | IMU, mic, pressure, humidity, proximity, colour |
| Nano RP2040 Connect | RP2040 @ 133 MHz | 264 KB | IMU, mic, WiFi, BLE |
| Portenta H7 | STM32H747 @ 480 MHz | 1 MB | WiFi, BLE, camera interface |
| Nano 33 IoT | SAMD21 @ 48 MHz | 32 KB | IMU, WiFi, BLE (limited TinyML use) |
The Nano 33 BLE Sense is the go-to TinyML board in the Arduino ecosystem — it packs a 9-axis IMU (LSM9DS1 or LSM6DS3, depending on revision), digital microphone (MP34DT05), barometric pressure, humidity, temperature, proximity, and RGB colour sensors all on a Nano form factor board, giving you rich multi-modal sensor input for diverse ML applications.
TinyML Frameworks: TFLite Micro vs Edge Impulse
TensorFlow Lite for Microcontrollers (TFLite Micro) is Google’s framework for running pre-trained TFLite models on embedded devices. It has a minimal C++ interpreter with no dynamic memory allocation (you provide a static arena buffer), supports a subset of TFLite operators, and integrates with the Arduino IDE via the “Arduino_TensorFlowLite” library. You train a model in Python on a PC using TensorFlow, convert it to TFLite format, quantise it to INT8 for size reduction, then embed the resulting .tflite file as a byte array in your sketch.
The workflow is powerful but involves significant ML expertise: data collection, preprocessing pipeline design, model architecture selection, training, evaluation, and quantisation. For ML practitioners, this is the right approach. For embedded engineers without ML background, it is steep.
Edge Impulse is a complete ML development platform that abstracts the entire model training pipeline into a web-based GUI. You collect sensor data directly from your Arduino, design a signal processing + ML pipeline in the browser, train the model on Edge Impulse’s cloud infrastructure, and download a pre-compiled Arduino library containing the model and inference code. Zero Python required.
Edge Impulse supports classification, regression, anomaly detection, and object detection. It supports all major Arduino TinyML boards natively with one-click data collection over USB. For beginners and for rapid prototyping, Edge Impulse is the recommended starting point. Many production TinyML products started as Edge Impulse prototypes.
Edge Impulse Workflow End-to-End
Here is the complete workflow for a TinyML project using Edge Impulse:
- Create a project at edgeimpulse.com and connect your Arduino Nano 33 BLE Sense via the Edge Impulse CLI (
edge-impulse-daemon). - Collect data: Use the Data Acquisition tab to record labelled sensor samples directly from the board. For gesture recognition, collect 2+ minutes of each gesture class. For keyword spotting, record 1-second audio clips of each keyword.
- Create Impulse: Define your signal processing block (e.g., Spectral Analysis for IMU data, MFE or MFCC for audio) and your learning block (Neural Network classifier, K-NN, or anomaly detection).
- Train: Edge Impulse trains your model on its cloud GPUs. Typical training takes 1–5 minutes. Review accuracy metrics and confusion matrix.
- Quantise and deploy: Enable INT8 quantisation, then click “Build” → “Arduino Library”. Download the .zip and add it to your Arduino IDE via Sketch → Include Library → Add .ZIP Library.
- Run inference: A ready-to-use inference sketch is included in the library examples. Flash it to your board and open Serial Monitor to see live classification results.
Project: Gesture Recognition with IMU
Gesture recognition classifies motion patterns from an IMU into predefined gestures — punch, flex, wave, etc. This was the first published TinyML demo on Arduino (Harvard/Google 2019).
Data collection sketch snippet (records accelerometer at 119 Hz for 1 second):
#include <Arduino_LSM9DS1.h>
#define SAMPLE_RATE 119
#define DURATION_MS 1000
void setup() {
Serial.begin(115200);
IMU.begin();
Serial.println("aX,aY,aZ,gX,gY,gZ");
}
void loop() {
float aX, aY, aZ, gX, gY, gZ;
// Wait for significant motion to trigger recording
while (!IMU.accelerationAvailable()) {}
IMU.readAcceleration(aX, aY, aZ);
if (abs(aX) + abs(aY) + abs(aZ) > 2.5) { // Threshold
unsigned long start = millis();
while (millis() - start < DURATION_MS) {
if (IMU.accelerationAvailable() && IMU.gyroscopeAvailable()) {
IMU.readAcceleration(aX, aY, aZ);
IMU.readGyroscope(gX, gY, gZ);
Serial.print(aX); Serial.print(',');
Serial.print(aY); Serial.print(',');
Serial.print(aZ); Serial.print(',');
Serial.print(gX); Serial.print(',');
Serial.print(gY); Serial.print(',');
Serial.println(gZ);
}
}
}
}
After training in Edge Impulse with 20+ samples per gesture, expect 90%+ accuracy on 3–4 distinct gestures. The compiled model for 4 gestures typically fits in ~15 KB of flash with INT8 quantisation — well within Nano 33 BLE Sense limits.
Project: Keyword Spotting with Microphone
Keyword spotting detects specific words (“yes”, “no”, “go”, “stop”) in continuous audio using a neural network trained on MFCC (Mel Frequency Cepstral Coefficients) features. The Arduino Nano 33 BLE Sense has a built-in PDM microphone (MP34DT05) that feeds 16 kHz 16-bit mono audio — exactly the format ML audio models expect.
Google’s Speech Commands dataset provides thousands of 1-second clips of common keywords, usable as training data in Edge Impulse. A 2-keyword model (“yes” vs “no” + noise/unknown) trained for 100 epochs typically achieves 92–96% accuracy and compiles to ~30 KB of flash including the MFCC preprocessing kernel.
The inference sketch runs a sliding 1-second window over continuous microphone input, computing MFCC features and running the model every 250 ms. When confidence exceeds a threshold (typically 0.7), the keyword is reported over Serial or triggers a GPIO output.
Project: Anomaly Detection for Predictive Maintenance
Anomaly detection learns the “normal” vibration signature of a machine (pump, motor, conveyor) and triggers an alert when the signature deviates — indicating a developing fault before physical failure. This is one of the most commercially valuable TinyML use cases.
Workflow:
- Mount the Arduino Nano 33 BLE Sense on the machine housing with double-sided tape or M3 screws
- Collect 5+ minutes of normal operation data (accelerometer + gyroscope at 100 Hz)
- In Edge Impulse, create an Impulse with Spectral Analysis (FFT) + K-means anomaly detection (no labelled fault data required)
- Deploy to the board; the model learns the FFT fingerprint of normal operation
- Attach an LED or buzzer to a GPIO — the sketch fires it when anomaly score exceeds threshold
This approach requires zero labelled fault data — you only need normal data for training. The K-means clustering model is tiny (~2 KB), leaving room for BLE telemetry to send anomaly scores to a phone app via the ArduinoBLE library.
FAQ
Can Arduino Uno run TinyML models?
No. The ATmega328P has only 2 KB of RAM — the TensorFlow Lite Micro interpreter alone requires 15–50 KB. TinyML requires an ARM Cortex-M processor with at least 256 KB RAM. The minimum Arduino board for TinyML is the Nano 33 BLE Sense. For AVR-class boards, very simple rule-based inference (threshold detection, simple statistics) is possible but not true neural network inference.
How much training data do I need for gesture recognition?
A general rule is 20+ samples per class for simple classification tasks. For gesture recognition with 4 classes, 20–50 samples per gesture (each 1–2 seconds long) typically gives 85–95% accuracy. More data always helps — 100+ samples per class is ideal for production deployments. Edge Impulse’s data augmentation (time stretching, noise injection) can synthetically expand smaller datasets.
What is quantisation and why does it matter for TinyML?
Quantisation converts model weights and activations from 32-bit floating-point (float32) to 8-bit integers (int8). This reduces model size by 4x and speeds up inference significantly on MCUs that lack FPUs. A float32 model that is 40 KB becomes 10 KB after INT8 quantisation. Most TinyML-capable Arduino boards have no hardware floating-point unit, making INT8 quantisation essential for performance.
How do I update a TinyML model on a deployed device?
Model updates require reflashing the firmware. On Arduino, this means connecting via USB for development boards, or implementing OTA (Over-The-Air) firmware updates for production devices. The Nano 33 BLE Sense supports OTA via BLE using the ArduinoOTA mechanism. The entire model is embedded as a constant byte array in the firmware, so updating the model = compiling and flashing new firmware.
What is the difference between Edge Impulse and TensorFlow Lite Micro?
TensorFlow Lite Micro is the low-level C++ inference engine — it runs a pre-trained, pre-converted model but does not handle data collection, preprocessing pipeline design, or model training. Edge Impulse is a full-stack platform built on top of TFLite Micro — it adds data collection, DSP blocks, model training, evaluation, and Arduino library generation. Use TFLite Micro directly if you are training models in Python and need full control. Use Edge Impulse for faster prototyping, especially if ML is not your primary expertise.
Start your TinyML journey with the right hardware. Browse Arduino boards and TinyML kits at Zbotic — official Arduino hardware, fast delivery across India, and expert support for your embedded AI projects.
Add comment