Machine learning in IoT: device or cloud
Short answer: Machine learning in IoT usually splits in two. Training happens on a server with the full data set. Inference, the step that makes a prediction, can run on the device when the model is small enough and the answer is needed in milliseconds, or in the cloud when the device has spare bandwidth and the model is large. Start from the memory and response time the device can afford, then pick the place that fits.
Where machine learning runs in an IoT system, on the device or in the cloud, the memory limits of microcontrollers, and the latency and privacy trade-offs.
This article covers where machine learning runs in an IoT system, the memory limits of microcontrollers, the latency and privacy differences between on-device and cloud inference, and the uses that suit each. It does not cover a step-by-step model training tutorial, the choice of a particular cloud machine learning service, and vendor benchmarks for named chips.
Machine learning in IoT means training a model on sensor data, then using it to make predictions on new readings. The training usually happens on a server. The prediction, called inference, can happen in two places: on the device itself or in the cloud. Most of the design work is deciding which.
Where the work happens
Training needs the full history and a lot of compute, so it normally runs on a server or in the cloud. Inference needs far less. What matters for inference is the time to an answer, how much data must leave the device, and how much memory the model needs.
The two places suit different jobs:
- On the device. A vibration sensor that must stop a motor within a few milliseconds, or a sensor that must stop a motor within milliseconds, is a good fit. The answer does not wait for a network, and the raw data never leaves the site.
- In the cloud. A model that needs many inputs, a large neural network or a history of thousands of devices suits the cloud. The device sends readings and gets a result back, so it needs a working connection and a budget for the data it sends.
Many systems use both. A small model on the device flags unusual readings, and the cloud model looks at the flagged data over weeks.
What a microcontroller can hold
The memory limit is the constraint that decides most projects. The MIT review of tiny machine learning by Lin and colleagues, posted to arXiv in 2024, compares the hardware directly. Microcontrollers have about three orders of magnitude less memory than mobile phones, and five to six orders of magnitude less than cloud GPUs. The review notes that microcontrollers have no DRAM and no operating system, and that their SRAM is often under 256 kB while flash is read-only at run time.
That is why a standard image model does not fit. The review reports that even an 8-bit quantized MobileNetV2 needs about 5.3 times more memory than a microcontroller can supply. Shrinking the model is the normal fix. Quantization stores the weights and activations at lower precision.
The review also points out that activation memory, not the number of parameters, is often the bottleneck. A model can have few weights and still need a lot of working memory during inference. Check the peak memory of the model on the target board, not just its file size.
Latency and privacy
The same 2025 systematic review, which follows PRISMA guidelines, covers TinyML use cases in real deployments. It reports that cloud-based IoT systems have latencies in the range of 10 to 500 ms. Its introduction gives 0 to 5 ms for TinyML inference, and its body gives a wider range of 0.18 to 300 ms for TinyML implementations. The review describes the accuracy drop in one comparative study as slight, from 95% to 85%, and the gain depends on the model and hardware.
Privacy is the other reason. Inference on the device means the raw readings do not travel to a server. The review notes that cloud-based data can be intercepted in transit, and that local processing lowers that exposure. It also lowers the bandwidth a fleet of devices needs, which lowers the bandwidth a fleet needs.
Uses that suit each
- Predictive maintenance. A model on a motor controller can flag a change in vibration pattern and raise an alarm locally. The full history for longer trend analysis can go to the cloud. Predictive maintenance with vibration sensors covers the sensor side.
- Anomaly detection in a building. A small model can flag an unusual pattern in power or temperature readings and send only the flagged events upstream.
- Classification of sounds or motion. A small model can classify a short window of sensor data on the device and send only the label.
- Fleet analytics. Training across thousands of devices, comparing sites and retraining the model belong in the cloud, where the data can be pooled.
How to choose
- Write down the response time the system needs. If the answer must come in milliseconds, or must work with no network, plan for on-device inference.
- Measure the memory the model needs at peak on the target board. If it does not fit, compress the model or move inference up a level.
- Decide what data may leave the site. Raw sensor data that is sensitive or costly to send is a reason to keep inference local.
- Plan the update path. A model on a device must be replaced through the same firmware process as the rest of the code, so firmware updates need a plan before the first model ships.
Start with the smallest model that answers the question, on the hardware that will be installed.
Sources
- Lin, Zhu, Chen, Wang and Han, Tiny Machine Learning: Progress and Futures, arXiv 2403.19076, 2024. Source for the memory comparison, the SRAM and flash limits, the MobileNetV2 figure and the activation-memory point.
- MDPI Sensors, systematic review of TinyML (2025), PMC article 12115890. Source for the cloud and TinyML latency ranges, the accuracy comparison, and the privacy and bandwidth points. The latency and accuracy figures are the review’s citation of a comparative study.
Common questions
What is machine learning in IoT?
It is the use of trained models on IoT data, such as readings from sensors, to classify something, spot an anomaly or predict a failure. The model is trained on collected data, then used to make predictions on new readings.
Can a microcontroller run machine learning?
Yes, but only small models. The MIT review on tiny machine learning notes that microcontrollers have about three orders of magnitude less memory than mobile phones and five to six orders less than cloud GPUs, and that SRAM is smaller than 256 kB on the boards it describes, though one example has 320 kB. A model that fits must be compressed, usually by quantization.
Is on-device machine learning faster than the cloud?
It removes the network round trip. A 2025 systematic review in MDPI Sensors reports cloud IoT latencies of 10 to 500 ms against 0 to 5 ms for TinyML inference, citing a comparative study. The gain depends on the network and the model, so measure it on the actual hardware.
Written by Hamza Rivera. Facts in this article follow the editorial policy: each one is behavior that is well established or set by the standard named in the text. A confirmed error is fixed in the article and its Updated date changes.