Edge AI: Decisions Made on the Device
Edge AI means the decision happens where the sensor is, not on a server across the internet. That changes the latency, the privacy and the failure behaviour, and it is much easier than the marketing makes it sound.
Cloud or edge: the trade you are actually making
Every time a device asks a server for an answer it pays for the round trip. A request to a cloud model typically takes a few hundred milliseconds of network time before the first word comes back, and that time is not yours to control, because it depends on someone else's load and the route your data takes. Move the same decision onto the device and the answer arrives in the time it takes your loop to run, which on a 16 MHz Arduino is well under a millisecond.
The other two reasons are privacy and continuity. An edge decision never leaves the room, so nothing has to be stored on someone else's server. And it keeps working when the network does not, which matters in a school where the wifi drops every afternoon at 3 pm. That single failure mode is worth more than the latency saving in most classroom projects.
What actually fits on a microcontroller
An Arduino Uno has 32 KB of flash for the program and 2 KB of RAM for variables, and runs at 16 MHz. That will not hold a language model. It will comfortably hold a threshold, a lookup table, a small decision tree, or a nearest-neighbour classifier with a few dozen reference readings, because all of those are just numbers in an array.
A three-layer network with 16, 8 and 1 inputs has 177 weights, which at one byte each is 177 bytes of flash, so the interesting question is never whether the weights fit. It is whether you can collect good training data, and that is a sensor and a logging problem rather than a computing problem. Put the fast reaction on the board and the slow classification wherever it fits, then decide the split with a number rather than a preference.
Step by step
-
Measure your loop before you optimise anything
Print millis() around the loop and know how long a decision takes today. If your loop already runs in under 1 ms, latency is not your problem and moving the model will not fix it.
-
Write down what must stay local
Any decision that depends on a sensor reading and a motor command belongs on the device. Anything that turns a few hundred samples into a summary can go to a bigger machine.
-
Replace a threshold with a tiny classifier
Log 50 labelled readings, then classify by nearest neighbour instead of a fixed threshold. It costs about 50 times 4 bytes of RAM and handles a two-axis sensor properly.
-
Add a confidence check
If the nearest reference is too far away, treat the reading as unknown and fall back to the safe default. This one line is what stops a small model from doing something silly on data it has never seen.
-
Log the decisions, not just the data
Print the reading, the label and the confidence over serial so you can find the failures. Most disappointing classifier results turn out to be bad labels rather than bad maths.
-
Unplug the network and test
If the project still behaves correctly with the wifi off, the edge split is real. If it needs the network, the decision has not actually moved.
What you'll need
| Item | Qty | Why |
|---|---|---|
| Arduino Uno R3 | 1 | 32 KB of flash, 2 KB of RAM and a 16 MHz clock: the honest limits of an edge device, and a good place to learn them. |
| ESP32 development board | 1 | Dual core at 240 MHz with wifi and Bluetooth built in, so you can keep the cloud option open while you test the local one. |
| HC-SR04 ultrasonic sensor | 1 | A two-axis observation, distance and rate of change, enough to separate an approaching object from one that is passing. |
| DHT11 temperature and humidity sensor | 1 | A slow variable, which makes it the right sensor for comparing a local decision with a cloud one. |
| LED bar graph module | 1 | Shows which class the classifier chose, so the mapping from label to output is visible. |
| USB cable and jumper wires | 1 set | For logging training data to a laptop, which is the part of the work students usually underestimate. |
Practise it before you build it
Every step above has a matching circuit in the ThinkEdge Learn simulator. The simulator runs a real
Arduino sketch against a modified-nodal-analysis solver, so digitalWrite actually drives the
LED on screen and the readings change when you change the wiring — no hardware, no burnt components.
The Mega has 4 hardware serial ports (Serial, Serial1, Serial2, Serial3). That means you can talk to 4 different devices at the SAME time — like a GPS, a Bluetooth module, an XBee radio, and the USB. Use 3 of those ports to read 3 different sensors in parallel and stream their data to the Serial Monitor as a CSV row every second. This is the foundation of every real Arduino data logger.
Mount an HC-SR04 ultrasonic sensor on top of a servo. Sweep the servo from 0° to 180° and back, and at each step measure the distance. Print the results to the Serial Monitor as "angle,distance" pairs. Open the Serial Plotter in the Arduino IDE to see a live radar-like graph of the room. With Processing on your computer, you can build a full visual radar.
In factories, conveyor belts carry products past a sensor that counts them. A simple "break-beam" sensor (a light source + photodetector) registers each object as it passes. In this project, you'll simulate the conveyor with your hand: every time you press the button (mimicking a product passing the sensor), the counter increments and the LED blinks. Add a buzzer to beep once for every 10 items. This is the same logic as a people counter at a door, a coin counter at a bank, or a bottle counter on a bottling line.
A 10-segment LED bar graph is the easiest way to visualize an analog input: spin a potentiometer and 1, 2, 3 ... 10 LEDs light up in sequence. This is a "VU meter" — the kind you see on stereo equipment. The Mega is ideal because it has 10 free digital pins without stealing any from the analog or serial pins. The same code can be extended to 20, 30, or 100 LEDs on a Mega.
The classic first Arduino project — blink the built-in LED on pin 13 — but done the RIGHT way. Most beginners use delay(1000) to make the LED blink, but delay() blocks the whole CPU so you can't do anything else while the LED blinks. The real Arduino idiom is to track time with millis() and only toggle the LED when enough time has passed. This is how every non-trivial Arduino sketch works.
A common real-world control system: read a sensor, compare to a threshold, switch an output on or off. Air conditioners, heaters, fans, and sprinklers all work this way. The DHT11 reads the room temperature, and a small 5V fan turns on at 30 °C or hotter and off at 27 °C or cooler — the same pattern that runs every thermostat on Earth. The 3 °C gap between the on- and off-thresholds (called hysteresis) stops it from flickering on/off every second when the temperature hovers right around 30 °C.
Common questions
What is the difference between edge AI and IoT?
IoT describes the connection: a device that talks to the internet. Edge AI describes where the decision is made. A temperature logger that uploads readings every minute is IoT with no AI on it. The same logger that decides on the device to switch on the fan, and reports only the decision, is doing edge AI. One is about the network, the other is about where the thinking happens.
Can an Arduino run AI?
It can run a small classifier, which is AI in the same sense that a thermostat is a controller. An Uno has 32 KB of flash and 2 KB of RAM, so you can store a few hundred reference readings or a few hundred weights, but not a language model. An ESP32 at 240 MHz with 520 KB of SRAM gives you more room and still costs about $12.
Does edge AI actually save money?
Sometimes, and the calculation is worth doing before you argue about it. A Raspberry Pi 5 running continuously at about 8 W uses roughly 5.8 kWh a month, which is under $1 at $0.15 per kWh. A cloud model bills per request instead, and that cost depends entirely on how often your device asks. For a classroom with 30 boards logging every 10 seconds, the difference between asking and not asking is the whole bill.
Related guides
Try the full simulator with your class
103 guided circuit projects, 21 lessons and an in-browser Arduino simulator. The first 15 projects are free, no account needed. NCERT Science mapping on 47 projects, with Arabic and English copy in the regional builds.