Predicting international soccer matches locally on an Arduino UNO R4 Minima using Edge Impulse Machine Learning
Roni Bandini — Buenos Aires, Argentina — June 2023
Can an Arduino UNO predict a soccer match using Machine Learning?
This project runs a complete TinyML classification model directly on an Arduino UNO R4 Minima. Historical international soccer match data was processed and used to train a model with Edge Impulse.
The user selects:
- 🏠 Home team
✈️ Away team- 🌎 Neutral or non-neutral location
The firmware automatically supplies the corresponding team IDs and FIFA rankings, executes the Machine Learning model locally, and displays the estimated probability of a home-team victory on a 16×2 LCD.
No computer is required once the model and sketch are deployed to the Arduino.
- ⚽ Soccer match forecasting with Machine Learning
- 🧠 TinyML inference directly on the Arduino UNO R4 Minima
- 📊 Model trained from historical international match data
- 🌍 Team identifiers generated from national-team data
- 🏆 FIFA ranking included as an input feature
- 🏟️ Neutral-location support
- 🎛️ Complete interface using five physical buttons
- 📟 Results displayed on a 16×2 LCD
- 📦 Ready-to-use Edge Impulse Arduino library included
- 🌐 Public Edge Impulse project available for cloning
- 💾 Training CSV files included in the repository
The project takes five numeric values and passes them directly to an Edge Impulse classifier:
home_team
away_team
home_team_fifa_rank
away_team_fifa_rank
neutral_location
The Arduino UI collects the match information, builds the feature vector and calls the classifier locally.
flowchart LR
USER["👤 User"]
LCD["📟 LCD + Keypad"]
TEAMS["⚽ Team Selection"]
FEATURES["🔢 5 Input Features"]
MODEL["🧠 Edge Impulse<br/>ML Model"]
R4["Arduino UNO R4<br/>Renesas RA4M1"]
RESULT["🏆 Home Win<br/>Probability"]
USER --> LCD
LCD --> TEAMS
TEAMS --> FEATURES
FEATURES --> R4
R4 --> MODEL
MODEL --> RESULT
RESULT --> LCD
Everything from user input to inference and result display runs on the microcontroller.
The original match database was processed before being imported into Edge Impulse.
flowchart LR
FIFA["⚽ Historical<br/>Match Data"]
CLEAN["🧹 Data<br/>Processing"]
IDS["🔢 Convert Teams<br/>to Numeric IDs"]
CSV["📄 CSV Dataset"]
EI["Edge Impulse"]
NN["🧠 Keras<br/>Classifier"]
LIB["📦 Arduino<br/>Library"]
UNO["Arduino UNO R4<br/>Minima"]
FIFA --> CLEAN
CLEAN --> IDS
IDS --> CSV
CSV --> EI
EI --> NN
NN --> LIB
LIB --> UNO
The original dataset contained much more information than could comfortably be entered using a five-button shield, so the model was reduced to five relevant input values.
| Feature | Description | Example |
|---|---|---|
home_team |
Numeric ID assigned to home team | 9 |
away_team |
Numeric ID assigned to away team | 28 |
home_team_fifa_rank |
FIFA ranking of home team | 1 |
away_team_fifa_rank |
FIFA ranking of away team | 3 |
neutral_location |
Match played at neutral venue | 0 / 1 |
The input tensor constructed by the Arduino is:
features[0] = idCountries[indexCountry1];
features[1] = idCountries[indexCountry2];
features[2] = fifaRank[indexCountry1];
features[3] = fifaRank[indexCountry2];
features[4] = neutralLocation;The firmware then invokes the Edge Impulse classifier:
EI_IMPULSE_ERROR res =
run_classifier(&features_signal, &result, false);The public Edge Impulse project uses two classification labels:
win
LoseDraw
For the device interface, the firmware extracts the win probability and displays it as the probability of the selected home team winning.
Example:
Argentina-Brazil
Home win 54.72%
The Machine Learning model is public and can be cloned:
https://studio.edgeimpulse.com/public/233190/latest
| Parameter | Value |
|---|---|
| Training samples | 13,940 |
| Testing samples | 3,456 |
| Dataset split | 80% / 20% |
| Input features | 5 |
| Classes | win, LoseDraw |
| Sample length | 1 second |
| Sample frequency | 1 Hz |
| Original model accuracy | 69% |
| Original model loss | 0.58 |
The model uses an Edge Impulse classification pipeline with a Keras classifier.
The repository includes the processed datasets used during development.
eiWIN.csv
eiLOSE.csv
eiDRAW.csv
countries.csv
Each match CSV uses the same five columns:
home_team
away_team
home_team_fifa_rank
away_team_fifa_rank
neutral_location
The original results were separated into:
- 🟢
eiWIN.csv - 🔴
eiLOSE.csv - 🟡
eiDRAW.csv
For the final classifier, losses and draws are combined into the LoseDraw class.
Machine Learning models operate on numeric data, so national-team names were converted to numeric identifiers.
The complete mapping is stored in:
countries.csv
The Arduino interface contains a smaller selection of teams for convenient navigation:
int idCountries[] = {
9, 42, 28, 215, 44, 77, 102, 136, 191, 214, 70
};
String countries[] = {
"Argentine",
"Chile",
"Brazil",
"USA",
"Colombia",
"Germany",
"Italy",
"Mexico",
"Spain",
"England",
"France"
};
int fifaRank[] = {
1, 31, 3, 13, 17, 14, 8, 15, 10, 5, 2
};These rankings correspond to the values used when the prototype was created in June 2023.
Additional national teams can be added using the IDs available in countries.csv.
| Component | Purpose |
|---|---|
| Arduino UNO R4 Minima | Runs the ML model |
| DFRobot LCD Keypad Shield | User input + prediction display |
| USB-C cable | Programming and power |
That is the complete hardware required.
The project was originally created as an early test of the Arduino UNO R4 Minima.
The board uses a Renesas RA4M1 32-bit Arm Cortex-M4 microcontroller.
Relevant specifications:
| Specification | UNO R4 Minima |
|---|---|
| MCU | Renesas RA4M1 |
| Architecture | Arm Cortex-M4 |
| Clock | 48 MHz |
| Flash | 256 kB |
| SRAM | 32 kB |
| EEPROM / Data flash | 8 kB |
| Operating voltage | 5 V |
| USB | USB-C |
| DAC | 12-bit |
| ADC | Up to 14-bit |
| CAN | Yes |
Its UNO form factor also makes it possible to use shields originally designed around previous generations of the Arduino UNO.
Official documentation:
https://docs.arduino.cc/hardware/uno-r4-minima/
The user interface is implemented with a 16×2 LCD Keypad Shield.
It provides:
UP
DOWN
LEFT
RIGHT
SELECT
The LCD is connected in the sketch as:
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);The buttons are read through analog input A0.
adc_key_in = analogRead(0);Different voltage ranges identify each button:
RIGHT < 50
UP < 250
DOWN < 450
LEFT < 650
SELECT < 850
The original build simply stacks the shield directly on the UNO R4 Minima.
DFRobot documentation:
https://wiki.dfrobot.com/_SKU_DFR0374__SKU_DFR0936_LCD_Keypad_Shield_V2.0
The interface is intentionally simple.
flowchart TD
START["⚽ Soccer Forecast"]
HOME["Select Home Team"]
AWAY["Select Away Team"]
NEUTRAL["Neutral Location?"]
FEATURE["Build Feature Vector"]
ML["🧠 Run ML Inference"]
RESULT["📟 Display<br/>Home Win %"]
RESET["Start New Forecast"]
START --> HOME
HOME --> AWAY
AWAY --> NEUTRAL
NEUTRAL --> FEATURE
FEATURE --> ML
ML --> RESULT
RESULT --> RESET
RESET --> HOME
Use:
UP / DOWN
to navigate through the teams.
The LCD shows the team and its FIFA ranking:
Select home team
Argentina (1)
Press:
SELECT
to confirm.
Repeat the process for the away team.
After selecting both teams, the Arduino asks:
Neutral location?
L: yes R: no
Internally:
LEFT → neutral_location = 1
RIGHT → neutral_location = 0
This value becomes the fifth feature passed to the classifier.
The five values are copied into:
float features[5];Edge Impulse wraps this array in a signal_t structure:
signal_t features_signal;
features_signal.total_length =
sizeof(features) / sizeof(features[0]);
features_signal.get_data =
&raw_feature_get_data;Inference is then executed locally:
EI_IMPULSE_ERROR res =
run_classifier(
&features_signal,
&result,
false
);The classifier results are available through:
result.classification[ix].label
result.classification[ix].valueWhen the win result is found, the Arduino converts the probability to a percentage:
lcd.print(
"Home win " +
String(result.classification[ix].value * 100) +
"%"
);Main Arduino application.
Contains:
- LCD interface
- Keypad handling
- Team selection
- FIFA ranks
- Feature vector creation
- Edge Impulse inference
- Prediction display
Precompiled Edge Impulse Arduino library containing the trained model.
Country-to-ID mapping used during dataset preparation.
Processed historical match data used to create the Machine Learning dataset.
Download and install the current Arduino IDE:
https://www.arduino.cc/en/software
Open:
Tools → Board → Boards Manager
Search for:
Arduino UNO R4
Install the Arduino Renesas UNO board package.
Select:
Arduino UNO R4 Minima
and choose the corresponding USB port.
Clone:
git clone https://github.com/ronibandini/soccerForecast.git
cd soccerForecastOr download the repository as a ZIP from GitHub.
The repository already contains the exported Arduino model:
ei-soccer-forecast-with-arduino-uno-r4-arduino-1.0.2.zip
In Arduino IDE select:
Sketch
→ Include Library
→ Add .ZIP Library
Choose:
ei-soccer-forecast-with-arduino-uno-r4-arduino-1.0.2.zip
The model can also be cloned and rebuilt directly from the public Edge Impulse project:
https://studio.edgeimpulse.com/public/233190/latest
Open:
soccer2.ino
The sketch includes:
#include <LiquidCrystal.h>
#include <Soccer_forecast_with_Arduino_Uno_R4_inferencing.h>Connect the UNO R4 Minima and upload the sketch.
Stack the DFRobot LCD Keypad Shield on the UNO R4 Minima.
No additional wiring is required.
After booting, the LCD shows:
Arduino Uno R4
Soccer forecast
followed by:
Roni Bandini
V1.0 6/2023
Then:
Select home team
Use:
UP / DOWN
and confirm with:
SELECT
Navigate again and press:
SELECT
Choose whether the game is at a neutral location.
The display shows:
Forecasting with
Machine Learning
and then the result:
Argentina-Brazil
Home win 52.37%
After a few seconds, the system returns to the home-team selection screen.
The Machine Learning model was trained with more teams than the eleven included in the Arduino interface.
To add another team:
- Find the team ID in:
countries.csv
- Add the ID to:
idCountries[]- Add the team name to:
countries[]- Add its FIFA rank to:
fifaRank[]- Increase:
arrayMaxaccordingly.
For example:
int idCountries[] = {
// existing IDs...
NEW_TEAM_ID
};
String countries[] = {
// existing teams...
"New Team"
};
int fifaRank[] = {
// existing rankings...
NEW_TEAM_RANK
};FIFA rankings:
https://www.fifa.com/fifa-world-ranking/men
The public Edge Impulse project can be cloned:
https://studio.edgeimpulse.com/public/233190/latest
The complete pipeline can then be modified:
flowchart LR
DATA["Historical Matches"]
FEATURES["Select Features"]
EI["Edge Impulse"]
TRAIN["Train Classifier"]
TEST["Test Model"]
EXPORT["Arduino Library"]
IDE["Arduino IDE"]
UNO["UNO R4 Minima"]
DATA --> FEATURES
FEATURES --> EI
EI --> TRAIN
TRAIN --> TEST
TEST --> EXPORT
EXPORT --> IDE
IDE --> UNO
After training:
Deployment
→ Arduino Library
→ Build
Download the ZIP and install it through Arduino IDE.
The generated library replaces:
ei-soccer-forecast-with-arduino-uno-r4-arduino-1.0.2.zip
The same architecture can be reused for other sports if historical match data is available.
The general model is:
historical data
↓
feature extraction
↓
classification model
↓
Edge Impulse
↓
Arduino library
↓
local inference
Possible applications include:
- 🏀 Basketball
- 🏈 American football
- 🎾 Tennis
- 🏉 Rugby
- 🏒 Hockey
- ⚾ Baseball
The Arduino-side application only needs to provide the same features used during model training.
The official Arduino Blog featured the project on June 28, 2023, describing the historical match dataset, Edge Impulse model and local inference running on the newly released UNO R4 Minima.
https://blog.arduino.cc/2023/06/28/predicting-soccer-games-with-tinyml-on-the-uno-r4-minima/
Complete build article covering the hardware, dataset, Machine Learning model, Edge Impulse deployment and Arduino interface.
https://www.hackster.io/roni-bandini/arduino-uno-r4-minima-tinyml-soccer-prediction-d16664
DFRobot Maker Community article covering the use of the LCD Keypad Shield with the UNO R4 and the Edge Impulse model.
https://community.dfrobot.com/makelog-313353.html
Spanish-language tutorial covering dataset preparation, Edge Impulse training, Arduino deployment and operation of the predictor.
https://bandini.medium.com/machine-learning-con-arduino-uno-r4-minima-84c8753d6c70
Italian coverage of the project and the UNO R4 TinyML implementation.
https://it.emcelettronica.com/fare-previsioni-sulle-partite-di-calcio-con-arduino-uno-r4-minima
Soccer forecast with Arduino Uno R4
https://studio.edgeimpulse.com/public/233190/latest
The project can be cloned into an Edge Impulse account to inspect the dataset, experiment with the classifier or generate a new Arduino deployment.
More Machine Learning and Edge AI projects:
Motorcycle helmet detection and traffic-light control using Texas Instruments AM62A, Edge Impulse and UNIHIKER.
https://github.com/ronibandini/TIAM62AITrafficLight
Offline Machine Learning prototype for predicting power outages using Arduino Nano 33 BLE Sense and Edge Impulse.
https://github.com/ronibandini/EdenOff
American Sign Language training system using Machine Learning, Edge Impulse and Texas Instruments AM62A.
https://github.com/ronibandini/ASLTrainer
Audio classification project using Edge Impulse to detect the reggaeton music genre.
https://github.com/ronibandini/reggaetonBeGone
Contracultura Maker is a book about maker culture, experimental electronics, technological autonomy, artificial intelligence and building singular machines instead of accepting technology as a closed system.
https://github.com/ronibandini/ContraculturaMaker
https://github.com/ronibandini/ContraculturaMaker/blob/main/ContraculturaMaker2.pdf
Roni Bandini Maker · AI Developer · Writer Buenos Aires, Argentina
🐙 GitHub https://github.com/ronibandini
🌐 Medium https://bandini.medium.com/
𝕏 X / Twitter https://x.com/RoniBandini
📸 Instagram https://www.instagram.com/ronibandini/
💼 LinkedIn https://www.linkedin.com/in/ronibandini/
Built with ⚽ + Arduino + TinyML.