Insights

Edge AI on Microcontrollers: How We Add AI to Hardware

Four steps of edge AI on a microcontroller: sensor data, train and shrink, run on the chip, decision

Edge AI on microcontrollers means running a trained machine-learning model directly on a small, low-power chip inside the product, with no cloud connection needed for each decision. It is how a sensor starts making decisions: recognising a gesture, flagging an anomaly or classifying a sound. Here is how it works in a real hardware product, and how we approach it.

What edge AI means in a product

The model lives in the firmware and runs on the device itself. Decisions are fast because there is no network round trip, the product keeps working offline, sensor data can stay on the device, and you do not pay cloud costs for every inference.

The tradeoff is size. A microcontroller has kilobytes of RAM and flash, not gigabytes, so the model, the sensors and the firmware have to be designed together.

Cloud or edge?

Cloud models can be larger and are easier to update, but they need a connection, add delay and send the data off the device. Edge models respond instantly, work offline and keep data local, but they have to fit the chip's memory and power budget. Many products use both: a small model on the device for quick decisions, and a larger one in the cloud for deeper analysis.

From sensor to decision, step by step

  1. Collect real data. Record signals from the actual sensor, in the conditions the product will face, not only on a clean bench.

  2. Train the model. Training happens on a computer, and the model is kept small on purpose.

  3. Shrink it. Quantisation converts the weights from 32-bit floating point numbers to 8-bit integers, so each weight takes a quarter of the memory. You then test that accuracy still holds on real data.

  4. Embed it. TensorFlow Lite Micro is an inference framework built for microcontrollers. The model is compiled into the firmware as an array, and memory is allocated statically, with nothing allocated at run time.

  5. Speed it up. On Arm Cortex-M chips, the CMSIS-NN library replaces generic kernels with optimised ones that speed up 8-bit inference.

  6. Wrap it in firmware. The sensor pipeline, the wake-up logic and the power management all have to work around the model.

What kinds of problems suit a microcontroller

Small models do well on signals from sensors: classifying gestures and motion, detecting anomalies in vibration or current, fusing several sensors into one decision, and recognising short voice commands.

They do not suit large image models or generative AI. Those need far more memory and compute than a microcontroller offers.

The hardware limits that decide the design

Memory. The model needs flash for its weights and RAM for its working data, and these limits come before everything else.

Power. Running inference costs energy. A model that runs all the time can undo a careful sleep design, as we explain in our guide to IoT battery drain.

Chip choice. The chip family sets the memory, the speed and the sleep current, as we cover in our guide to ESP32 vs nRF52 battery life.

Data quality. A model is only as good as the signals it sees. Noisy power and poor sensor layout hurt accuracy before the software ever gets a chance.

How we integrate AI into hardware

Edge AI is one of the twelve services we offer, next to the circuit design, the firmware and the production work, so the model is not an add-on from a separate team. We plan the sensor circuit, the firmware and the AI pipeline together, with the memory, power and connectivity budget set first.

Not every model belongs on the chip. On our coaching device, the models run in the cloud. We also tested on-device inference with TensorFlow Lite Micro during that project, and it remains part of our toolkit for products where latency, privacy or battery life make the cloud a poor fit. Models change as you collect more data, so we plan over-the-air updates from the start, as we explain in our guide to OTA firmware updates.

Mistakes to avoid

Training on clean lab data and deploying in a noisy field is the most common one. The second is choosing the chip before you know how big the model is. The third is running inference continuously when a simple trigger could wake it. The fourth is having no way to update the model once units are in the field.

Start from the constraint, not the model

The best edge AI products start from the budget: how much memory, how much power and how much accuracy the product really needs. If you are adding intelligence to a hardware product, talk to us about firmware development and AI on edge before you choose the chip. Not sure whether your idea fits on a microcontroller? Tell us what it does and we will tell you what we would try first.

Hire us