Gesture detector
This guide demonstrates using Consentium's TinyML library with an MPU6050 sensor for gesture recognition on an ESP32 or compatible Edge board. The example collects accelerometer and gyroscope data to recognize gestures using a TensorFlow Lite model.
Overview
The example uses an MPU6050 sensor to collect accelerometer and gyroscope data. It detects a gesture based on movement exceeding a threshold, then collects and processes data to recognize gestures using a TensorFlow Lite model. The recognized gestures are printed to the Serial Monitor.
Prerequisites
Hardware: ESP32 or compatible Edge board, MPU6050 sensor.
Software: Consentium's TinyML library, EdgeNeuron library, TensorFlow Lite Micro, MPU6050 library.
Code Explanation
Includes and Constants
MPU6050_light.h
: Include the MPU6050 library.Wire.h
: Include the I2C communication library.EdgeNeuron.h
: Include the TensorFlow Lite wrapper for Arduino.model.h
: Include the header file for the TensorFlow Lite model.mpu
: Create an instance of the MPU6050 sensor.accelerationThreshold
: Threshold for detecting significant movement.numSamples
: Number of samples required for a gesture.inputLength
: Total input tensor size.tensorArenaSize
: Size of memory allocated for TensorFlow Lite tensors.GESTURES
: Array of gesture labels.NUM_GESTURES
: Number of gestures.
Setup Function
Initializes serial communication.
Starts I2C communication for the MPU6050 sensor.
Initializes and calibrates the MPU6050 sensor.
Initializes the TensorFlow Lite model and sets up the tensor arena.
Loop Function
Waits for movement that exceeds the threshold to start gesture detection.
Collects and normalizes accelerometer and gyroscope data for a defined number of samples.
Fills the input tensor with normalized data.
Runs inference once all samples are collected.
Prints the probability of each gesture recognized by the model.
License
This code is licensed under the MIT license. All text in the license header must be included in any redistribution.
Last updated