<aside> ā˜šŸ»

Based on this example: https://blog.tensorflow.org/2019/11/how-to-get-started-with-machine.html

</aside>

<aside> āœ… The code is available here: https://www.dropbox.com/scl/fo/uc08na1k2rs6q1ztywa7f/ALMWzjkywXIqcnMMvqD05QE?rlkey=qzw00e3cj9pfsfslnxg6huoa3&dl=0

</aside>

Training a TensorFlow Lite Micro model for Arduino

This section outlines the steps to deploy TinyML code on an Arduino Nicla Vision to detect specific movement patterns using its internal IMU (Inertial Measurement Unit). The goal is to provide a comprehensive guide, covering the entire process—from creating the dataset to deploying the final model on the hardware.

We'll begin by capturing motion data with the Arduino Nicla Vision, then use TensorFlow to train a model on this data. Finally, we'll deploy the trained classifier onto the board for real-time motion detection.

This example relates to what is known as predictive maintenance. The idea is to recognize a pair of movements that are supposed to indicate the regular movement of a machine and alert when a non-standard movement is detected.

Setting up the Arduino IDE

Following the steps below set up the Arduino IDE application to upload inference models to your board and download training data from it in the next section.

1.- Install the Mbed OS core for Nicla boards in the Arduino IDE.

image.png

Next, go to Tools > Board > Arduino Mbed OS Nicla Boards and select Arduino Nicla Vision. Having your board connected to the USB, you should see the Nicla on Port and select it.

Now go to the Library Manager and Search for and install theĀ ArduTFLite and Chirale_TensorFlowLite Ā libraries

image.png

Next, search for and install theĀ Arduino_LSM6DSOXĀ library:

image.png

Streaming sensor data from the Arduino board

First, we need to capture some training data. You can capture sensor data logs from the Arduino board.

We’ll be using a pre-made sketch IMU_Capture.ino which does the following: