+
Trento 󰏢, April 9th, 2025
Edge AI 🪄
Bringing Intelligence to
Embedded Devices
Leonardo Cavagnis
+
3
Whoami
Leonardo Cavagnis
Sr. Firmware Engineer @ Arduino
Community Builder @ ItalianEmbedded
🧡 Passionate about sharing knowledge
4
Agenda
➔ Edge AI Basics ✨
➔ Building an AI/ML Model 🧠
➔ Hands-on Demo 󰞵
5
Introduction to Edge AI
✨
6
What is Edge AI ?
AI that runs directly on the device
Data processing
near the source,
directly on devices
Algorithms to simulate
the human cognitive
process
Traditional Cloud AI
7
Why Edge AI Matters?
Low Latency Energy Saving
Processing locally
reduces delay
compared to Cloud AI
Offline
Since computations
happen locally, the
device can function
without an internet
connection
Privacy
Minimizing the need to
send sensitive data to
the Cloud
Reducing data
transmission and cloud
dependency lowers
power consumption
8
Edge AI in Action
Healthcare
Wearable devices,
Remote patient
monitoring
Smart Home
Voice assistants,
Smart appliances
Industrial
Predictive maintenance,
Anomaly detection
Automotive
ADAS,
Autonomous vehicle
9
Building an AI Model 󰠻
10
A Simplified View
Deployment
Model
Testing
Data
Collection
Problem
Definition
Model
Training
“Identify if a 😽 is
present in an image”
󰢛
The AI learns to
recognize cats in
images
✅❌
Evaluate model
performance
using new cat
images
11
What is Machine Learning (ML)?
Artificial Intelligence
Machine
Learning
Creating machines simulating
human intelligence
Algorithms enabling computers to
learn from data
Supervised
Learning
Unsupervised
Learning
Classifying cat vs no-cat images
using labeled data
Clustering animal images based
on visual features without labels
12
Neural Networks & Deep Learning
Computational models with
interconnected artificial neurons,
inspired by the brain 🧠
Subset of ML where
neural networks learn from large dataset
Machine Learning
Neural
Networks
Deep
Learning
13
Neural Network: The basics
An Artificial Neural Network (ANN) consists of layers of neurons that process information
- Each neuron is a unit that performs calculations
Neuron
Input
tensor
x
Weights
W ∑
Bias
b
Activation
function
f(z)
Output
tensor
y
x[] y[]
z = W⋅x + b
y = f(z)
14
Introduction to Tiny ML
Embedded
System
Machine
Learning
What is an Embedded System?
Devices with limited resources
designed to perform specific tasks
Tiny ML
Application of Machine Learning on
embedded devices (e.g., microcontrollers)
Uses techniques to
reduce model size:
🔢 Quantization
✂ Pruning
🧪 Distillation
…
15
Edge AI, Edge ML & Tiny ML
Edge AI
Edge ML
Tiny ML
AI processing on edge devices
Machine Learning on edge devices
Machine Learning on low-power embedded devices
16
Hands-on Demo 󰞵
17
ML Magic Wand 🪄
A gesture recognition system based on a Machine Learning Model using Movement sensor data.
18
ML Magic Wand 🪄
Sensor data are processed by a model to recognize 2 gestures, using Arduino and TensorFlow.
🧠Arduino
Nano Matter
Board
Movement
Sensor
Board
💡Color bar
Board
Ring
gesture
Wing
gesture
3D printed
carrier
19
What is
Arduino?
󰢃
20
What is Arduino? 👍
Arduino is a global leader
in open-source hardware and software
It provides a complete platform for making
interactive projects
Designed to be accessible to all
Large and active community (> 30M developers)
21
Arduino Mission
“Enable anyone to innovate by making complex technologies simple to use”
Student Maker Business
22
The setup: TensorFlow + Colab + Python
An open-source ML
framework by Google,
enabling the development
and deployment of AI models
from cloud to edge.
A cloud-based Jupyter
Notebook to write and
execute Python code easily
and quickly.
+ =
Easy-to-use,
HW-Accelerated
environment to
build AI model
23
Recall: The Pipeline
Deployment
Model
Testing
Data
Collection
Problem
Definition
Model
Training
24
Classification problem
Deployment
Model
Testing
Data
Collection
Problem
Definition
Model
Training
The problem involves gesture recognition using
accelerometer data from an IMU sensor.
The goal is to classify 2+1 gestures:
1. Wing (W)
2. Ring (O)
3. No Gesture (idle or unrecognized movements)
👀 This is a Supervised Learning classification problem.
TinyML Model
Probabilities
[Wing, Ring, No Gesture]
Accelerometer data
[P1,P2,P3]
[ax, ay, az]
25
Define model input
Deployment
Model
Testing
Data
Collection
Model
Training
Problem
Definition
TinyML Model
IMU sensor readings frequency = 100 Hz
Sample duration = 2 secs approx.
2s * 100 Hz = 200
200 tuples of accelerometer [aX,aY,aZ] sensor data
for each sample
→ a total of 600 (200 * 3) data points/sample
Accelerometer data
recorded for 2 secs
200 * [aX, aY, aZ]
26
Data preprocessing
Deployment
Model
Testing
Data
Collection
Model
Training
Problem
Definition
Collected raw data is processed to make it suitable for model training:
- Normalization
- Noise filtering
- Interpolation
- Feature Extraction
- …
normalized_value = (raw_value_acc + 2000) / 4000
Normalization
Scaling data to specific range, typically [0,1] → preventing large values and improve stability
Accelerometer data is expressed in milliG (mG) in in a range [-2000, +2000]
27
Let’s collect the data!
Deployment
Model
Testing
Data
Collection
Model
Training
Problem
Definition
Perform multiple Wing (W) and Ring (O) gestures, including unrecognized movements.
1⃣ Wait for a movement
→ The system monitors sensor data
until a threshold is exceeded.
2⃣ Start recording
→ Data is collected for 2 seconds.
3⃣ Output the samples
→ The recorded data is printed to the
Serial monitor in CSV format.
28
Dataset splitting
Deployment
Model
Testing
Data
Collection
Model
Training
Problem
Definition
Dataset is divided into 3 subsets:
1. Training [60%]
Train the machine learning model.
2. Validation [20%]
Monitor its performance during training.
3. Test [20%]
Evaluate the model's performance after training.
Validation Test
Training
29
Model Architecture
Deployment
Model
Testing
Data
Collection
Model
Training
Problem
Definition
Training: model learns patterns and relationships in the data to make predictions.
The Multi-Layer Perceptron (MLP) is the simplest ANN architecture for classification tasks.
Features
✅ Fully Connected Layers
✅ At Least One Hidden Layer
✅ Non-Linear Activation Functions
30
Model Architecture with TensorFlow
Deployment
Model
Testing
Model
Training
Problem
Definition
A Multi-Layer ANN can be defined using:
import tensorflow as tf
model = tf.keras.Sequential()
Data
Collection
For our problem, we can design a network with:
● 256 neurons in the hidden layer
model.add(tf.keras.layers.Dense(256, activation='relu'))
● 3 neurons in the output layer, each representing one of the 3 gestures to classify
model.add(tf.keras.layers.Dense(3, activation='softmax'))
…
Wing
Ring
None
600 = 200 * [aX,aY,aZ]
256
3
31
Model Architecture with TensorFlow
Deployment
Model
Testing
Model
Training
Problem
Definition
A typical Multi-Layer Perceptron (MLP) architecture consists of two hidden layers.
import tensorflow as tf
model = tf.keras.Sequential()
Data
Collection
For our problem, we can design a network with:
● 256 neurons in the first hidden layer
model.add(tf.keras.layers.Dense(256, activation='relu'))
● 128 neurons in the second hidden layer
model.add(tf.keras.layers.Dense(128, activation='relu'))
● 3 neurons in the output layer, each representing one of the 3 gestures to classify
model.add(tf.keras.layers.Dense(3, activation='softmax'))
…
…
Wing
Ring
None
600 = 200 * [aX,aY,aZ]
32
Model Training with TensorFlow
Deployment
Model
Testing
Model
Training
Problem
Definition
Set training parameters:
model.compile(optimizer='rmsprop',
loss='categorical_crossentropy',
metrics=['accuracy'])
…Let’s start the training!
model.fit(inputs_train, outputs_train,
epochs=100, batch_size=8,
validation_data=(inputs_validate, outputs_validate))
Validation Test
Training
Data
Collection
33
Monitoring Training Results
Deployment
Model
Testing
Model
Training
Problem
Definition
Monitor the loss and accuracy curves for both the training and validation data:
Epoch 3/100
32/32 [==============================] -
0s 8ms/step - loss: 1.0856 - accuracy: 0.4233 - val_loss: 1.0800 - val_accuracy:
0.4200
If the loss decreases while
the accuracy increases
→ the model is learning well ✅
Data
Collection
34
Evaluate Model Performance
Deployment
Model
Testing
Model
Training
Problem
Definition
We need to check how well the model generalizes to unseen data.
This is done by evaluating its predictions on the test dataset.
predictions = model. predict(inputs_test)
One useful method is to analyze the
Confusion Matrix
Validation Test
Training
Data
Collection
35
From “Big” to Tiny
Deployment
Model
Testing
Model
Training
Problem
Definition
Data
Collection
To run the model on a microcontroller, we need to convert it to a TinyML model
using TensorFlow Lite.
converter = tf.lite. TFLiteConverter.from_keras_model(model)
converter.optimizations = [tf.lite.Optimize. DEFAULT]
converter.target_spec.supported_ops = [tf.lite.OpsSet. TFLITE_BUILTINS_INT8]
tflite_model = converter. convert()
Integer Quantization
Converting float to nearest
8-bit fixed-point numbers
⚡Optimizations:
- LATENCY
- SIZE
- DEFAULT (trade-off)
36
FlatBuffer: Implementing ANN on MCU
Deployment
Model
Testing
Model
Training
Problem
Definition
Data
Collection
FlatBuffer is commonly used to store neural network models in a
compact, fast-access structure.
010
101
FlatBuffer
Efficient data serialization format
1. Header
Model metadata
2. Operators
A list of operations
3. Tensors
Data structure for inputs/outputs
4. Parameters
Numerical values used in the inference
37
Let’s code!
Deployment
Model
Testing
Model
Training
Problem
Definition
Data
Collection
TinyML Model
Probabilities
[Wing, Ring, No Gesture]
Accelerometer data
200 * [ax, ay, az]
The gesture with the highest
probability could be
considered the detected one
38
Color feedback
Deployment
Model
Testing
Model
Training
Problem
Definition
Data
Collection
Blue
Waiting for significant gesture
Off
Inferencing
in progress (2 seconds)
Green
Wing gesture detected
Yellow
Ring gesture detected
39
Challenges and Future 🔮
40
Challenges in Edge AI Development
🤩
Real-time processing
Lower latency
Reduced bandwidth usage
😰
Limited resources (RAM, CPU)
Trade-off between power & performance
Difficult model optimization
41
Future of Edge AI
⚡ Increased Power on MCUs
Advances in microcontroller capabilities and the emergence of specialized
controllers (NPU, VPU, ...)
⚙ Optimized Algorithms
Continuous improvements in algorithms and the development of new
frameworks
🚀 New Applications
Emerging sectors, including smart wearables, drones, Industry 4.0, and more
42
“Future” of Edge AI 󰣻
Source:
tefal.com.sg/Cooking-appliances/Rice-Cookers/RK736B-EASY-RICE-PLUS-spherical-pot-rice-cooker-1-8L/p/7211004623
43
References
Arduino Nano Matter
https://docs.arduino.cc/hardware/nano-matter/
ML Magic Wand with Arduino Nano Matter
https://docs.arduino.cc/tutorials/nano-matter/ml-magic-wand/
Google AI LiteRT (former TensorFlow Lite)
https://ai.google.dev/edge/litert
Thank you! 🫶
Trento 󰏢, April 9th, 2025
Leonardo Cavagnis
✉ l.cavagnis@arduino.cc
🌎 leonardocavagnis.github.io
+

Edge AI: Bringing Intelligence to Embedded Devices

  • 1.
  • 2.
    Trento 󰏢, April9th, 2025 Edge AI 🪄 Bringing Intelligence to Embedded Devices Leonardo Cavagnis +
  • 3.
    3 Whoami Leonardo Cavagnis Sr. FirmwareEngineer @ Arduino Community Builder @ ItalianEmbedded 🧡 Passionate about sharing knowledge
  • 4.
    4 Agenda ➔ Edge AIBasics ✨ ➔ Building an AI/ML Model 🧠 ➔ Hands-on Demo 󰞵
  • 5.
  • 6.
    6 What is EdgeAI ? AI that runs directly on the device Data processing near the source, directly on devices Algorithms to simulate the human cognitive process Traditional Cloud AI
  • 7.
    7 Why Edge AIMatters? Low Latency Energy Saving Processing locally reduces delay compared to Cloud AI Offline Since computations happen locally, the device can function without an internet connection Privacy Minimizing the need to send sensitive data to the Cloud Reducing data transmission and cloud dependency lowers power consumption
  • 8.
    8 Edge AI inAction Healthcare Wearable devices, Remote patient monitoring Smart Home Voice assistants, Smart appliances Industrial Predictive maintenance, Anomaly detection Automotive ADAS, Autonomous vehicle
  • 9.
    9 Building an AIModel 󰠻
  • 10.
    10 A Simplified View Deployment Model Testing Data Collection Problem Definition Model Training “Identifyif a 😽 is present in an image” 󰢛 The AI learns to recognize cats in images ✅❌ Evaluate model performance using new cat images
  • 11.
    11 What is MachineLearning (ML)? Artificial Intelligence Machine Learning Creating machines simulating human intelligence Algorithms enabling computers to learn from data Supervised Learning Unsupervised Learning Classifying cat vs no-cat images using labeled data Clustering animal images based on visual features without labels
  • 12.
    12 Neural Networks &Deep Learning Computational models with interconnected artificial neurons, inspired by the brain 🧠 Subset of ML where neural networks learn from large dataset Machine Learning Neural Networks Deep Learning
  • 13.
    13 Neural Network: Thebasics An Artificial Neural Network (ANN) consists of layers of neurons that process information - Each neuron is a unit that performs calculations Neuron Input tensor x Weights W ∑ Bias b Activation function f(z) Output tensor y x[] y[] z = W⋅x + b y = f(z)
  • 14.
    14 Introduction to TinyML Embedded System Machine Learning What is an Embedded System? Devices with limited resources designed to perform specific tasks Tiny ML Application of Machine Learning on embedded devices (e.g., microcontrollers) Uses techniques to reduce model size: 🔢 Quantization ✂ Pruning 🧪 Distillation …
  • 15.
    15 Edge AI, EdgeML & Tiny ML Edge AI Edge ML Tiny ML AI processing on edge devices Machine Learning on edge devices Machine Learning on low-power embedded devices
  • 16.
  • 17.
    17 ML Magic Wand🪄 A gesture recognition system based on a Machine Learning Model using Movement sensor data.
  • 18.
    18 ML Magic Wand🪄 Sensor data are processed by a model to recognize 2 gestures, using Arduino and TensorFlow. 🧠Arduino Nano Matter Board Movement Sensor Board 💡Color bar Board Ring gesture Wing gesture 3D printed carrier
  • 19.
  • 20.
    20 What is Arduino?👍 Arduino is a global leader in open-source hardware and software It provides a complete platform for making interactive projects Designed to be accessible to all Large and active community (> 30M developers)
  • 21.
    21 Arduino Mission “Enable anyoneto innovate by making complex technologies simple to use” Student Maker Business
  • 22.
    22 The setup: TensorFlow+ Colab + Python An open-source ML framework by Google, enabling the development and deployment of AI models from cloud to edge. A cloud-based Jupyter Notebook to write and execute Python code easily and quickly. + = Easy-to-use, HW-Accelerated environment to build AI model
  • 23.
  • 24.
    24 Classification problem Deployment Model Testing Data Collection Problem Definition Model Training The probleminvolves gesture recognition using accelerometer data from an IMU sensor. The goal is to classify 2+1 gestures: 1. Wing (W) 2. Ring (O) 3. No Gesture (idle or unrecognized movements) 👀 This is a Supervised Learning classification problem. TinyML Model Probabilities [Wing, Ring, No Gesture] Accelerometer data [P1,P2,P3] [ax, ay, az]
  • 25.
    25 Define model input Deployment Model Testing Data Collection Model Training Problem Definition TinyMLModel IMU sensor readings frequency = 100 Hz Sample duration = 2 secs approx. 2s * 100 Hz = 200 200 tuples of accelerometer [aX,aY,aZ] sensor data for each sample → a total of 600 (200 * 3) data points/sample Accelerometer data recorded for 2 secs 200 * [aX, aY, aZ]
  • 26.
    26 Data preprocessing Deployment Model Testing Data Collection Model Training Problem Definition Collected rawdata is processed to make it suitable for model training: - Normalization - Noise filtering - Interpolation - Feature Extraction - … normalized_value = (raw_value_acc + 2000) / 4000 Normalization Scaling data to specific range, typically [0,1] → preventing large values and improve stability Accelerometer data is expressed in milliG (mG) in in a range [-2000, +2000]
  • 27.
    27 Let’s collect thedata! Deployment Model Testing Data Collection Model Training Problem Definition Perform multiple Wing (W) and Ring (O) gestures, including unrecognized movements. 1⃣ Wait for a movement → The system monitors sensor data until a threshold is exceeded. 2⃣ Start recording → Data is collected for 2 seconds. 3⃣ Output the samples → The recorded data is printed to the Serial monitor in CSV format.
  • 28.
    28 Dataset splitting Deployment Model Testing Data Collection Model Training Problem Definition Dataset isdivided into 3 subsets: 1. Training [60%] Train the machine learning model. 2. Validation [20%] Monitor its performance during training. 3. Test [20%] Evaluate the model's performance after training. Validation Test Training
  • 29.
    29 Model Architecture Deployment Model Testing Data Collection Model Training Problem Definition Training: modellearns patterns and relationships in the data to make predictions. The Multi-Layer Perceptron (MLP) is the simplest ANN architecture for classification tasks. Features ✅ Fully Connected Layers ✅ At Least One Hidden Layer ✅ Non-Linear Activation Functions
  • 30.
    30 Model Architecture withTensorFlow Deployment Model Testing Model Training Problem Definition A Multi-Layer ANN can be defined using: import tensorflow as tf model = tf.keras.Sequential() Data Collection For our problem, we can design a network with: ● 256 neurons in the hidden layer model.add(tf.keras.layers.Dense(256, activation='relu')) ● 3 neurons in the output layer, each representing one of the 3 gestures to classify model.add(tf.keras.layers.Dense(3, activation='softmax')) … Wing Ring None 600 = 200 * [aX,aY,aZ] 256 3
  • 31.
    31 Model Architecture withTensorFlow Deployment Model Testing Model Training Problem Definition A typical Multi-Layer Perceptron (MLP) architecture consists of two hidden layers. import tensorflow as tf model = tf.keras.Sequential() Data Collection For our problem, we can design a network with: ● 256 neurons in the first hidden layer model.add(tf.keras.layers.Dense(256, activation='relu')) ● 128 neurons in the second hidden layer model.add(tf.keras.layers.Dense(128, activation='relu')) ● 3 neurons in the output layer, each representing one of the 3 gestures to classify model.add(tf.keras.layers.Dense(3, activation='softmax')) … … Wing Ring None 600 = 200 * [aX,aY,aZ]
  • 32.
    32 Model Training withTensorFlow Deployment Model Testing Model Training Problem Definition Set training parameters: model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy']) …Let’s start the training! model.fit(inputs_train, outputs_train, epochs=100, batch_size=8, validation_data=(inputs_validate, outputs_validate)) Validation Test Training Data Collection
  • 33.
    33 Monitoring Training Results Deployment Model Testing Model Training Problem Definition Monitorthe loss and accuracy curves for both the training and validation data: Epoch 3/100 32/32 [==============================] - 0s 8ms/step - loss: 1.0856 - accuracy: 0.4233 - val_loss: 1.0800 - val_accuracy: 0.4200 If the loss decreases while the accuracy increases → the model is learning well ✅ Data Collection
  • 34.
    34 Evaluate Model Performance Deployment Model Testing Model Training Problem Definition Weneed to check how well the model generalizes to unseen data. This is done by evaluating its predictions on the test dataset. predictions = model. predict(inputs_test) One useful method is to analyze the Confusion Matrix Validation Test Training Data Collection
  • 35.
    35 From “Big” toTiny Deployment Model Testing Model Training Problem Definition Data Collection To run the model on a microcontroller, we need to convert it to a TinyML model using TensorFlow Lite. converter = tf.lite. TFLiteConverter.from_keras_model(model) converter.optimizations = [tf.lite.Optimize. DEFAULT] converter.target_spec.supported_ops = [tf.lite.OpsSet. TFLITE_BUILTINS_INT8] tflite_model = converter. convert() Integer Quantization Converting float to nearest 8-bit fixed-point numbers ⚡Optimizations: - LATENCY - SIZE - DEFAULT (trade-off)
  • 36.
    36 FlatBuffer: Implementing ANNon MCU Deployment Model Testing Model Training Problem Definition Data Collection FlatBuffer is commonly used to store neural network models in a compact, fast-access structure. 010 101 FlatBuffer Efficient data serialization format 1. Header Model metadata 2. Operators A list of operations 3. Tensors Data structure for inputs/outputs 4. Parameters Numerical values used in the inference
  • 37.
    37 Let’s code! Deployment Model Testing Model Training Problem Definition Data Collection TinyML Model Probabilities [Wing,Ring, No Gesture] Accelerometer data 200 * [ax, ay, az] The gesture with the highest probability could be considered the detected one
  • 38.
    38 Color feedback Deployment Model Testing Model Training Problem Definition Data Collection Blue Waiting forsignificant gesture Off Inferencing in progress (2 seconds) Green Wing gesture detected Yellow Ring gesture detected
  • 39.
  • 40.
    40 Challenges in EdgeAI Development 🤩 Real-time processing Lower latency Reduced bandwidth usage 😰 Limited resources (RAM, CPU) Trade-off between power & performance Difficult model optimization
  • 41.
    41 Future of EdgeAI ⚡ Increased Power on MCUs Advances in microcontroller capabilities and the emergence of specialized controllers (NPU, VPU, ...) ⚙ Optimized Algorithms Continuous improvements in algorithms and the development of new frameworks 🚀 New Applications Emerging sectors, including smart wearables, drones, Industry 4.0, and more
  • 42.
    42 “Future” of EdgeAI 󰣻 Source: tefal.com.sg/Cooking-appliances/Rice-Cookers/RK736B-EASY-RICE-PLUS-spherical-pot-rice-cooker-1-8L/p/7211004623
  • 43.
    43 References Arduino Nano Matter https://docs.arduino.cc/hardware/nano-matter/ MLMagic Wand with Arduino Nano Matter https://docs.arduino.cc/tutorials/nano-matter/ml-magic-wand/ Google AI LiteRT (former TensorFlow Lite) https://ai.google.dev/edge/litert
  • 44.
    Thank you! 🫶 Trento󰏢, April 9th, 2025 Leonardo Cavagnis ✉ l.cavagnis@arduino.cc 🌎 leonardocavagnis.github.io +