TinyML in Practice: Computer Vision on Battery-Powered Edge Devices
Computer vision used to be a cloud-first workload. A camera captured a frame, compressed it, shipped it over Wi-Fi or LTE, and a GPU server ran a large model. That architecture still works for many products, but it breaks down when the device is battery-powered, bandwidth-constrained, privacy-sensitive, or deployed in places where connectivity is expensive. TinyML changes the equation by running useful vision models directly on microcontrollers and low-power edge processors.
This article is a practical guide to building battery-powered computer vision systems with TinyML. It covers hardware constraints, model optimization, deployment pipelines, security, MLOps, and the tradeoffs that decide whether inference belongs on the device, a gateway, or the cloud.
What TinyML Means for Computer Vision
TinyML is not simply a smaller version of server-side machine learning. It is a different engineering discipline. The model must fit within kilobytes of RAM, run on a processor without an FPU or with a limited NPU, and consume milliwatts instead of watts. The camera, memory bus, radio, and power management are part of the same design problem.
A typical TinyML vision pipeline has five stages:
- Capture: a low-power camera or image sensor captures frames, often at low resolution and low frame rate.
- Preprocess: cropping, grayscale conversion, resizing, normalization, and sometimes motion detection or region-of-interest extraction.
- Inference: a quantized neural network classifies, detects, or segments the frame.
- Postprocess: thresholding, non-maximum suppression, tracking, or temporal smoothing.
- Act or transmit: the device triggers a local action, stores a result, or sends metadata over a low-power radio.
The goal is not always to replace the cloud. Often the edge model acts as a gatekeeper. It answers a simple question such as is there a person, is the machine vibrating abnormally, or is this leaf diseased, and only then wakes a larger model or a radio link.
The Constraints That Shape the Design
Energy and Battery Life
Energy is the hardest constraint. Every inference costs energy, but so do camera capture, memory access, and radio transmission. A radio sending a single image can consume more energy than hundreds of local inferences. This is why the best TinyML designs optimize the entire duty cycle, not just the model.
- Duty cycling: keep the MCU in deep sleep and wake on a timer, motion sensor, or low-power vision trigger.
- Frame rate reduction: one frame per second or one frame per minute may be enough for wildlife, agriculture, or occupancy monitoring.
- Resolution reduction: a 96×96 grayscale frame can be sufficient for coarse classification.
- Event-driven capture: use a PIR sensor or always-on low-power vision chip to wake the main processor only when something changes.
Memory and Compute
Microcontrollers often have 64 KB to 512 KB of RAM and 256 KB to 2 MB of flash. A model must share that memory with the RTOS, communication stacks, camera buffers, and application logic. TensorFlow Lite for Microcontrollers uses a static tensor arena, so memory planning matters. Fragmentation, stack usage, and DMA buffers can break a model that fits on paper.
Compute is equally constrained. A Cortex-M4 at 100 MHz may deliver only a few hundred million operations per second. An NPU such as Arm Ethos-U55 or a vendor-specific accelerator can improve throughput by 10x to 100x, but only for supported operators and data types.
Latency and Responsiveness
Cloud inference adds network latency. For a security camera, a doorbell, or an industrial safety system, waiting 500 ms for a round trip may be unacceptable. Edge inference can react in milliseconds. However, edge models are usually less accurate than large cloud models. The right balance depends on the cost of a false positive versus the cost of a missed detection.
Bandwidth, Cost, and Connectivity
Cellular data plans, satellite links, and LoRaWAN have monthly data caps. Sending raw video is often impossible or uneconomical. Sending only inference results, bounding boxes, or small thumbnails reduces cost and extends battery life. In remote deployments, the network may be unavailable for hours or days, so the device needs local storage and store-and-forward logic.
Privacy and Security
On-device inference keeps sensitive images local. A camera that detects falls in a home can send an alert without uploading video. This reduces regulatory risk under privacy laws such as GDPR or CCPA. But edge devices still need secure boot, signed firmware updates, encrypted storage, and protection against model extraction or adversarial inputs.
Hardware Landscape for Edge Vision
There is no single best hardware platform. The choice depends on frame rate, resolution, model complexity, battery capacity, and cost.
Microcontrollers
- Arm Cortex-M0 and M0+: ultra-low power, suitable for simple always-on classification and keyword spotting, but limited for vision.
- Arm Cortex-M4 and M7: DSP instructions and optional FPU. Common in STM32, nRF, and NXP families. Good for 96×96 or 128×128 grayscale models.
- ESP32 and ESP32-S3: integrated Wi-Fi and Bluetooth, with vector instructions on the S3. Popular for connected camera prototypes.
- Raspberry Pi RP2040 and RP2350: dual-core, flexible PIO, good for custom camera interfaces, but no hardware NPU.
- RISC-V MCUs: emerging AI extensions and open-source toolchains, with growing vendor support.
Edge Accelerators and NPUs
- Arm Ethos-U55 and U65: microNPUs designed for Cortex-M and Cortex-A systems. They support int8 and sometimes int16 operations.
- Google Coral Edge TPU: USB and module form factors for higher-power edge devices. Good for MobileNet-style models.
- NVIDIA Jetson: more power-hungry but capable of real-time multi-camera vision and transformer-based models.
- Vendor NPUs: Kneron, Hailo, Syntiant, and others offer specialized inference at different power points.
Cameras and Sensors
The camera can dominate the power budget. Rolling shutter sensors are cheap but can distort moving objects. Global shutter sensors are better for robotics and fast motion. Monochrome sensors reduce data and power. Event cameras output only pixel changes, which can be extremely power-efficient for motion-triggered vision, but they require different algorithms and tooling.
- OV2640 and OV5640: common JPEG and RGB sensors for ESP32 and STM32 cameras.
- HM01B0 and HM0360: low-power monochrome sensors often used in always-on vision.
- Global shutter sensors: better for industrial inspection and tracking.
Model Architectures That Fit
Not every modern vision model is suitable for TinyML. The best architectures use depthwise separable convolutions, aggressive downsampling, and efficient activation functions. They avoid large fully connected layers and expensive attention blocks unless the hardware supports them.
- MobileNetV1 and V2: classic depthwise separable backbones. Good starting point for 96×96 to 224×224 inputs.
- EfficientNet-Lite: scaled versions that balance accuracy and latency, but some variants may be too large for MCUs.
- SqueezeNet: small model size, but older and often beaten by MobileNet variants.
- Tiny YOLO and YOLO-Nano: object detection on edge devices. Detection is harder than classification, so expect lower resolution and lower frame rates.
- MCUNet and MCUNetV2: neural architecture search designed for microcontroller memory constraints.
- MicroNets: a family of models optimized for TinyML applications.
For classification, a small MobileNetV2 with width multiplier 0.35 and input 96×96 can run on a Cortex-M7 with a few hundred kilobytes of RAM. For detection, a nano YOLO variant at 160×160 may require an NPU or a higher-end MCU.
Optimization Techniques
Optimization is not a single step. It is a loop: train, convert, measure on device, and repeat. The most important techniques are quantization, pruning, distillation, and architecture search.
Quantization
Quantization converts floating-point weights and activations to lower precision, usually int8. It reduces model size by 4x, cuts memory bandwidth, and enables faster integer arithmetic. There are two main approaches:
- Post-training quantization: easier and faster. It requires a representative calibration dataset. Accuracy can drop, especially for small models and object detection.
- Quantization-aware training: simulates quantization during training. It usually recovers most accuracy and is preferred when the model is sensitive.
Per-channel quantization often works better than per-tensor quantization for weights. Mixed precision can keep sensitive layers in int16 or float, but hardware support varies. Always verify operator support in your inference runtime.
Pruning and Sparsity
Pruning removes weights or channels that contribute little to accuracy. Unstructured pruning creates sparse matrices that are hard to accelerate on general-purpose MCUs. Structured pruning removes entire filters or channels and can reduce real latency. Iterative pruning with fine-tuning is more effective than one-shot pruning.
Knowledge Distillation
A large teacher model trains a small student model. The student learns from soft labels, which contain more information than hard class labels. Distillation can improve small-model accuracy without increasing inference cost. It is especially useful when you have a powerful cloud model but need a tiny edge model.
Neural Architecture Search
NAS automates the design of efficient architectures. Hardware-aware NAS includes latency, memory, and energy in the search objective. MCUNet is an example that co-designs the model and the inference engine. NAS can be expensive, but it often finds architectures that hand-tuning misses.
Operator and Memory Optimization
Inference engines such as TensorFlow Lite for Microcontrollers, CMSIS-NN, and Ethos-U drivers use optimized kernels for convolution, depthwise convolution, pooling, and activation. To get the best performance:
- Fuse operations where possible, such as convolution plus batch normalization plus ReLU.
- Avoid dynamic shapes and unsupported operators.
- Reuse tensor memory with an arena allocator.
- Keep the model in flash and stream weights instead of copying everything to RAM.
- Align tensors and buffers for DMA and vector instructions.
A Deployment Pipeline for TinyML Vision
A reliable TinyML workflow has clear stages. Skipping stages leads to models that work in a notebook but fail in the field.
- Define the decision: specify the exact output, confidence threshold, latency budget, and energy budget. For example, detect a person at 2 meters with at least 90 percent recall and less than 50 mJ per inference.
- Collect edge-realistic data: capture images with the same camera, lens, lighting, and mounting angle as the final device. Include night, rain, motion blur, and occlusion.
- Label and split: create training, validation, and test sets. Keep test data from different days or locations to measure generalization.
- Train a baseline: start with a known efficient architecture. Do not begin with a giant model unless you plan to distill it.
- Optimize and quantize: apply pruning, distillation, and quantization-aware training. Track accuracy and latency after each step.
- Convert to device format: export to TensorFlow Lite, ONNX, or a vendor format. Use the vendor compiler to check operator support.
- Integrate with firmware: manage camera buffers, preprocessing, inference, and radio tasks. Use a real-time operating system or a careful superloop.
- Measure on hardware: record latency, RAM, flash, energy per inference, and temperature. Use a power profiler and a logic analyzer.
- Validate in the field: run a pilot with real users and real conditions. Monitor false positives, false negatives, and battery life.
- Deploy and monitor: use signed OTA updates, canary rollout, and telemetry for model drift and device health.
Example: Battery-Powered Wildlife Camera
Consider a solar-assisted camera trap that classifies animals. The device must run for months, send only relevant events over LoRaWAN, and avoid uploading raw images.
- Hardware: Cortex-M7 MCU at 200 MHz, 512 KB RAM, 2 MB flash, monochrome global shutter camera, PIR sensor, LoRaWAN radio, 10 Wh battery, small solar panel.
- Model: MobileNetV2 width 0.35, input 96×96 grayscale, int8 weights and activations, 120 KB flash, 80 KB RAM.
- Pipeline: PIR wakes the MCU. The camera captures one frame. A motion filter removes empty frames. The model classifies among deer, boar, person, and empty. If confidence is above 0.85, the device sends a class ID, timestamp, and confidence over LoRaWAN. A small JPEG thumbnail is stored locally and sent only when the gateway requests it.
- Energy: sleep current 5 microamps, inference energy 15 mJ, radio transmission 50 mJ. With 20 events per day, the average power is low enough for solar replenishment.
This example shows the central TinyML tradeoff: a small model with moderate accuracy, combined with smart gating, can deliver more value than a large model that drains the battery or saturates the network.
Performance Metrics That Matter
Accuracy alone is not enough. For edge vision, you need a balanced scorecard.
- Top-1 or mAP: task accuracy on a held-out edge test set.
- Latency: time from camera trigger to inference result, including preprocessing and postprocessing.
- Energy per inference: joules or millijoules per frame. This determines battery life.
- Peak memory: tensor arena, stack, camera buffers, and communication buffers.
- Flash footprint: model weights, runtime, and application code.
- False positive rate: critical for alerts and privacy-sensitive applications.
- False negative rate: critical for safety and security.
- Thermal behavior: sustained inference can throttle or damage components in sealed enclosures.
Measure these on the target hardware. Emulators and desktop benchmarks often miss memory bottlenecks, cache behavior, and DMA contention.
Security and Privacy for Edge Vision
Edge inference improves privacy, but it also creates new attack surfaces. A device that processes images locally may store sensitive data, and an attacker who gains physical access can extract firmware or manipulate the camera.
- Secure boot: verify firmware signatures before execution.
- Signed OTA updates: encrypt and authenticate update packages. Support rollback only to trusted versions.
- Secure storage: encrypt model weights and configuration if they are valuable or private.
- Adversarial robustness: test against physical patches, glare, and unusual lighting. TinyML models are often more vulnerable than large models.
- Data minimization: do not store raw frames unless necessary. If you must, encrypt them and set a retention policy.
- Debug hardening: disable or lock JTAG and UART debug ports in production.
MLOps for a Fleet of Tiny Devices
Managing thousands of edge devices is different from managing cloud models. You cannot assume reliable connectivity, and a bad update can brick devices in the field.
- Model registry: version every model with training data, hyperparameters, quantization settings, and target hardware.
- OTA pipeline: build, sign, and stage firmware images. Use canary groups and automatic rollback.
- Telemetry: send aggregated metrics such as inference count, confidence distribution, error codes, battery voltage, and temperature. Avoid raw images unless the user opts in.
- Drift detection: compare on-device confidence distributions with validation baselines. A sudden drop may indicate camera degradation, lighting changes, or a new environment.
- A/B testing: run two model versions on different device groups. Measure both accuracy proxies and energy impact.
- Fleet health: monitor devices that stop reporting. Silent failures are common when power or connectivity degrades.
Choosing the Right Tier: MCU, Gateway, or Cloud
Not every problem belongs on a microcontroller. Use a tiered architecture when possible.
| Tier | Typical Hardware | Best For | Tradeoffs |
|---|---|---|---|
| MCU | Cortex-M, ESP32, small NPU | Always-on trigger, simple classification, low power | Limited accuracy, small models, no complex detection |
| Edge gateway | Raspberry Pi, Jetson, x86 with NPU | Multi-camera analytics, object detection, local storage | Higher power, more cost, needs maintenance |
| Cloud | GPU or TPU clusters | Training, heavy inference, fleet analytics, complex models | Latency, bandwidth, privacy, recurring cost |
A common pattern is a cascade: a microcontroller detects motion, a gateway runs a larger model to classify the event, and the cloud trains new models and monitors fleet health. This keeps the expensive resources where they add the most value.
Tools and Frameworks
The TinyML ecosystem is maturing quickly. The right tool depends on your hardware and team.
- TensorFlow Lite for Microcontrollers: mature runtime for MCUs, with a growing operator set.
- Edge Impulse: end-to-end platform for data collection, training, and deployment to many edge targets.
- STM32Cube.AI: converts models to optimized C code for STM32 microcontrollers.
- CMSIS-NN: optimized neural network kernels for Arm Cortex-M processors.
- Arm Ethos-U: compiler and runtime for microNPUs.
- ONNX Runtime: cross-platform inference for gateways and some edge devices.
- ExecuTorch: PyTorch edge deployment runtime with growing microcontroller support.
- Apache TVM: compiler stack that can target diverse accelerators.
- OpenVINO: optimized inference on Intel edge hardware.
- NVIDIA TensorRT and DeepStream: high-performance vision on Jetson and discrete GPUs.
Common Pitfalls and How to Avoid Them
- Training on clean data: edge cameras produce noise, motion blur, and bad exposure. Augment and collect real data.
- Ignoring preprocessing: the model may expect normalized RGB, but the device provides raw Bayer or grayscale. Match preprocessing exactly.
- Quantizing too late: quantization changes model behavior. Use quantization-aware training from the start when possible.
- Forgetting memory fragmentation: a static tensor arena helps, but camera and network buffers can still fragment heap memory. Preallocate and monitor.
- Underestimating radio energy: sending one image can cost more than thousands of inferences. Send metadata first.
- Overlooking thermal limits: continuous inference in a sealed enclosure can overheat. Duty cycle and heatsink design matter.
- Using unsupported operators: check the compiler and runtime before training. A single unsupported op can block deployment.
- Skipping field validation: lab accuracy rarely matches field performance. Pilot with real conditions and real users.
Future Directions
TinyML vision is moving quickly. Several trends will shape the next generation of battery-powered devices.
- Event cameras: they output sparse changes instead of full frames, reducing power and latency for motion-driven tasks.
- Transformers on edge: efficient attention variants and NPUs are making small transformers possible, though convolutions remain dominant for low-power vision.
- On-device learning: personalization and adaptation without sending raw data to the cloud. This is still difficult on MCUs but advancing.
- Federated learning: collaborative training across devices while keeping data local.
- RISC-V AI extensions: open instruction sets with vector and matrix operations could lower the cost of edge AI.
- Neuromorphic computing: spiking neural networks promise ultra-low power for always-on vision, but tooling and algorithms are still maturing.
Conclusion
TinyML makes computer vision possible on battery-powered devices, but it demands whole-system thinking. The model, camera, memory, radio, and power supply must be designed together. Start with a clear decision, collect edge-realistic data, choose an efficient architecture, quantize early, measure on hardware, and deploy with security and fleet management in mind.
The most successful edge vision systems are not always the ones with the most accurate model. They are the ones that balance accuracy, latency, energy, privacy, and cost for the specific deployment. With the right pipeline, a microcontroller can see, decide, and act without ever sending a frame to the cloud.

