Sign in Start for free

TinyML: Slope control for robots with Arduino Pro



Today smart household appliances can be found in almost every home and they really simplify our daily routine. One of the most useful and smart inventions of the last decade, the vacuum cleaner robot, is sometimes not as smart as we want it to be. It can be stuck or blocked by a carpet, a doorstep, or any other obstacle in its way.

Leonardo Cavagnis, an AI developer and a true connoisseur of Italian shoes and smart solutions for life has solved this problem once and for all. A hack to avoid this situation is to calculate the robot’s path in real-time in relation to the floor, and perform decisions according to its current position. 

In this tutorial, you’ll learn how to approach this problem using a data-based technique, tiny machine learning, and how to implement an inclination estimator system based on an accelerometer by running a compact ML model on an Arduino Proboard, Nicla Sense ME. 


Project Overview

The model will be deployed on 32-bit Nicla Sense ME which has 4 sensors: motion, magnetometer, pressure, and gas sensor. This board is suitable for projects that need to combine sensor measurements and AI tasks on a small device.

Since Nicla provides strong computational power given low consumption, the embedded model should be really tiny and accurate. Model training and deployment on an MCU will be performed with the help of Neuton, as it allows the user to automatically build compact neural networks that don’t need additional compression.


The given problem can be approached as a Regression task and a Multi classification task. We’ll create models for both approaches to compare them further. The experiment implies the following stages:

  • Capturing a training dataset: For each inclination degree, 10 measurements will be captured and stored in a CSV file. Each measurement will be composed of 50 accelerometer and 50 gyroscope readings.
  • Training models with Neuton: Two different models (Regression and Multi classification) should be trained using the same dataset.
  • Deploying models on Nicla Sense ME.

TinyML Model Training

Upon capturing a training dataset and converting it to a CSV file, you can proceed with model training. Here, we train 2 different models using the same dataset: one for the Regression task type and another for the Multi classification task.

For training with Neuton, take the following steps:

  • Create “New Solution” for each task: “Inclination estimator Reg” and “Inclination estimator Mul”.
  • Upload the training dataset file and verify whether it meets the Neuton requirements (a green check will appear next to the file name). Then, click “OK”.
  • In the target variable section, select “Target” and click “Next”.
  • Once the dataset is successfully validated, Neuton automatically provides the available ML task types. Select “Regression” and “Multi Classification” accordingly.
  • As the model will run on an MCU, enable the TinyML mode for both solutions.
  • Turn on “Advanced mode”, go to “Advanced settings”, select the 32-bit depth in a dropdown menu, and click “Start Training”.

The Neuton platform will automatically train the model and notify you by changing the status to “Training completed”. This signifies that the model has reached the best predictive power.


Model Deployment on Nicla

To generate the C libraries of the two models, click on the “Download” button of each solution.


The Neuton C-Library consists of:

  • /model: the neural network model
  • /preprocessing: a set of functions used to perform pre-processing operations: data manipulation, data filtering, etc.
  • neuton.c—neuton.h: a set of functions used by the application logic to execute the model and read prediction results.

Library integration is simple and consists of 3 steps.

To see all the details and outcomes of this project, check the full write-up.

Want to create your own project? Try Neuton for free right now! 

Stay updated, join the community