This project aims to demonstrate how to implement a TinyML model on an m5ATOM, a board that uses the ESP32 as the main microcontroller. We will use the MPU sensor integrated into the m5ATOM to detect motion patterns and, based on those, display numbers on the board’s LED matrix. This approach provides a practical and efficient way to use AI in low-power, limited-hardware devices.
- M5ATOM Matrix
- MPU6050 sensor (integrated into the m5ATOM)
- Arduino IDE
- Edge Impulse Studio
- Internet connection
- USB-C cables
- Computer with command-line access
#Process
It is necessary to set up the development environment in the Arduino IDE to get started. This involves adding the plugins required to program the m5ATOM within the IDE. Follow these links for more information and to complete the setup:
- Guide for Arduino IDE and m5ATOM
- Documentation for programming the m5ATOM
- Installation of m5ATOM support in Arduino IDE
- MPU sensor configuration in m5ATOM
Create a code to send the data:We must create code in Arduino to send sensor data to Edge Impulse. The code will transmit the sensor information (accelerometer and gyroscope) via a serial connection, to be used in training the model. We will use the following references as guides:
Using the Data Forwarder:With Edge Impulse's Data Forwarder, we can connect the m5ATOM to the platform and send sensor data for processing. This step is performed in the terminal, requiring you to log in to your Edge Impulse account. You’ll also need to specify information about the sensors being used (accelerometer and gyroscope).link: https://docs.edgeimpulse.com/docs/tools/edge-impulse-cli/cli-data-forwarder
Data acquisition in Edge Impulse:It is important to gather a balanced dataset for the three classes we will classify: '1', '2', and 'idle'. Class '1' will represent the motion associated with number one, and class '2' will correspond to the motion for number two, both detected through the accelerometer and gyroscope sensors. The 'idle' class will represent a resting state or no detected motion.
When creating the model (Impulse) in Edge Impulse, you will need to specify the board you are using. Although the m5ATOM is not officially supported on the platform, you can select a board with similar characteristics, such as the ESP32-EYE. Be sure to configure the correct hardware settings to optimize the model's performance on the m5ATOM.
Use theEdge Impulse Deployment area to create the model for the m5atom matrix.
Since the m5ATOM is based on the ESP32, the model must be deployed as a compatible library for ESP32. In the Arduino IDE, you will need to include the generated library and use the example provided for ESP32 in Edge Impulse.
You can adapt the sample code that Edge Impulse provides for classifying data using the following link:
Add extra codeFinally, we will add additional code that allows numbers to be displayed on the m5ATOM's LED matrix according to the class inferred by the model. This will allow the corresponding number (one, two, or idle) to be displayed on the LED screen based on the detected motion pattern.
An explanation of the code, here is an image to simplify principal functions in the code:
https://docs.google.com/drawings/d/1mkMyzFLfI9oi0JP1fP92Z-KVeme4SgHAmVSIpTCsDTY/edit?usp=sharing
Comments