AI on small boards
What you’ll learn
- What “edge AI” and “TinyML” mean
- The train → convert → deploy workflow
- Which hardware fits which kind of model
AI at the edge
Edge AI means running a trained model on the robot itself instead of sending data to the cloud. That’s faster (no network delay), works offline and keeps data private. TinyML is the extreme version: tiny models on microcontrollers using milliwatts.
The workflow
- Collect data: recordings of sounds, accelerometer movements or photos, with labels.
- Train a model on a computer (or a free online tool).
- Convert/compress it for the target: for example to TensorFlow Lite / LiteRT format, often with quantization (8-bit numbers instead of 32-bit) to make it 4× smaller.
- Deploy to the board and run inference: feed in new data, get predictions.
Beginner-friendly tools: Google Teachable Machine (train image, sound or pose models in the browser) and Edge Impulse (data collection to deployment for many boards).
What runs where
| Hardware | Good for |
|---|---|
| Microcontrollers (ESP32, Arduino Nano 33 BLE / RP2040 class) | Keyword spotting, gesture recognition from an IMU, simple sensor anomaly detection |
| Raspberry Pi 5 | Small image classifiers and detectors at modest frame rates |
| Pi + AI accelerator (e.g. Raspberry Pi AI Kit), Jetson-class boards | Real-time object detection |
| Boards that combine a Linux processor and a microcontroller (e.g. Arduino UNO Q) | Vision/AI on the Linux side, real-time control on the MCU side |
Limits
Small models make mistakes, especially with data unlike their training set. Always add rule-based safety checks around AI decisions on a moving robot.
Example: gesture-controlled robot (TinyML)
- Data: 50 recordings each of “circle”, “shake” and “still” from an IMU on a wristband.
- Model: a small neural network, a few kilobytes after quantization.
- Deploy: on an ESP32; the predicted gesture is sent to the robot (“circle” = spin, “shake” = stop).
Example: safety wrapper
String gesture = runModel(); // e.g. "forward"float confidence = modelConfidence(); // 0..1if (confidence < 0.8) gesture = "stop"; // unsure? do the safe thingif (frontDistance() < 15) gesture = "stop"; // rules beat AI near obstaclesTrain a modelEasy
Use Google Teachable Machine (teachablemachine.withgoogle.com) to train an image model with two classes, such as “thumbs up” and “open hand”. How many example images did it need to work well?
Pick the hardwareMedium
Choose hardware for: wake-word detection on a battery robot; detecting people in a live camera feed; recognising 3 hand gestures from an IMU. A microcontroller (TinyML); a Pi with an AI accelerator or a Jetson-class board; a microcontroller.
Failure modesHard
Your model was trained indoors and now runs outside in bright sun. List two things that might go wrong and two ways to reduce the risk. Lower accuracy from unfamiliar lighting, and confident wrong answers. Fix: add outdoor examples to the training data; require high confidence and keep rule-based safety checks.
Quick check
Finished this lesson?