About the example#
The workshop gesture recognition project demonstrates an end-to-end embedded machine-learning application on the ESP32-C5. It reads three-axis angular velocity from the BMI270 gyroscope and runs a TensorFlow Lite Micro model locally, without sending sensor data to a cloud service. The project is based on the upstream ESP-SensairShuttle gesture recognition example and contains the files used in this workshop.
The included model recognizes three classes:
- Counterclockwise circle
- V gesture
- Unknown movement
The application waits until the combined motion on the three gyroscope axes exceeds a configurable threshold. It then collects 200 samples from each axis and either prints the data for training or passes the resulting 200 × 3 tensor to the model.
The Boot button switches between two operating modes:
- Automatic inference mode — the default mode. Motion above the threshold starts inference, and the predicted class and confidence are printed to the serial monitor.
- Data collection mode — press Boot before performing a gesture. The application prints the captured gyroscope values so they can be added to a training dataset.
On this page, you will download, build, flash, and verify the supplied application. The following assignments use the same example to collect a new dataset, train and convert a model, and deploy it back to the ESP32-C5.
Download the gesture recognition example#
Choose either Git or a ZIP archive to download the source code.
Option 1: Clone with Git#
Clone the workshop code repository:
- Open the Command Palette and run
Git: Clone. - Paste
https://github.com/espressif/developer-portal-codebase.git. - Select a destination folder.
VS Code can open the downloaded repository when cloning finishes.
git clone --depth 1 https://github.com/espressif/developer-portal-codebase.git
cd developer-portal-codebaseOption 2: Download the ZIP archive#
Download the workshop codebase from GitHub:
Download developer-portal-codebase (ZIP)
Extract developer-portal-codebase-main.zip, open a terminal, and enter the extracted directory:
cd /path/to/developer-portal-codebase-mainGraphical alternative: Extract the archive with Finder, File Explorer, or your desktop archive manager. You do not need to open a terminal; continue with the VS Code instructions in the next step.
1. Enter the example directory#
From the repository root, enter the gesture recognition project:
Select File → Open Folder and open:
developer-portal-codebase/content/workshops/esp-tflite-micro/gesture_recognitioncd content/workshops/esp-tflite-micro/gesture_recognitionFor a ZIP download, the first directory is named developer-portal-codebase-main.
2. Activate ESP-IDF#
When the project folder is open, the ESP-IDF extension uses its configured environment automatically.
- Run
ESP-IDF: Doctor Commandfrom the Command Palette. - Confirm that the report identifies ESP-IDF v6.1.
Open a terminal with the ESP-IDF v6.1 environment activated. If you completed the previous page in another terminal, run the activation command printed by EIM again.
Verify the active version:
idf.py --versionThe command should report ESP-IDF v6.1.
3. Connect the hardware#
- Install the BMI270 and BMM350 daughterboard in the Shuttle Board connector.
- Confirm that the shuttle-board voltage jumper is set to 3.3 V.
- Connect the ESP-SensairShuttle to your computer through its USB-C port using a data-capable cable.
The LCD and BME690 daughterboard are not required.
4. Set the target and build#
- Open the Command Palette and run
ESP-IDF: Set Espressif Device Target. - Select
esp32c5. - Run
ESP-IDF: Build Your Project. - Follow the build output in VS Code until it reports a successful build.
idf.py set-target esp32c5
idf.py buildA successful build ends with instructions for flashing the application.
5. Find the serial port#
Identify the board’s serial port:
- Run
ESP-IDF: Select Port to Usefrom the Command Palette. - Select the port that appears when the ESP-SensairShuttle is connected.
The selected port is displayed in the VS Code status bar.
ls /dev/cu.*ls /dev/ttyUSB* /dev/ttyACM*COM port.6. Flash and monitor#
- Run
ESP-IDF: Build, Flash and Start a Monitor on Your Devicefrom the Command Palette. - Select UART if prompted.
- Use the trash-can icon in the VS Code Terminal panel to stop the monitor.
This command uses the target and serial port selected in the previous steps.
Replace <PORT> with the serial port detected above:
idf.py -p <PORT> flash monitorPress Ctrl+] to exit the serial monitor.
If flashing does not start automatically, hold the Boot button, briefly press Reset, and release Boot when the download begins.
7. Check the gesture recognition application#
The example starts in automatic inference mode. Move the board in a counterclockwise circle or V shape and check the monitor for the predicted class and confidence.
Expected output:
I (9992) Model Pipeline: Motion detected: Counterclockwise circle (confidence: 100.0%)
I (11719) Model Pipeline: Motion detected: Unknown (confidence: 95.0%)
I (13232) Model Pipeline: Motion detected: V (confidence: 99.9%)Timestamps and confidence values vary between runs. Ordinary movements should usually be classified as Unknown.
Long-press and release the Boot button to switch modes:
- Collection mode: Press Boot, then perform the gesture immediately. Collection begins when the sum of the absolute three-axis gyroscope values exceeds the configured trigger threshold. The application prints the sampled values.
- Automatic inference mode: No button press is required. Motion above the trigger threshold runs inference automatically.
