Tags:
create new tag
view all tags

The Magic Wand Example

Introduction

The magic wand example shows how to detect gestures using an accelerometer. Different types of accelerometers are easily available:

The MPU6050 and the MPU9250 gave hardware offset registers which allow calibrating the device. When the device is horizontally mounted and stationary (not moving) we expect the values:
  • 0,0,1g for the measured acceleration in x, y and z, z pointing in the direction of gravity.
  • and 0,0,0 for the gyroscope
The measured values may however differ. Setting the hardware offsets for acceleration and gyroscope permit to correct for the offset. The application note;
http://www.digikey.com/en/pdf/i/invensense/mpu-hardware-offset-registers describes these registers.

  • The LIS2DH MEMS digital output motion sensor from ST Microelectronics is an ultra low power high performance 3 axis accelerometer.
lis3dh.png

Hardware

I mounted the accelerometer onto a WeMos D1 prototype board. With the triple base and the CPU this makes up for a stable assembly that can easily be moved without cable contact problems.

mpu6050assembly.png

Hardware connections

The MPU6050 is connected to the WeMos D1 bus as follows:

MPU6050 WeMos D1 bus GPIO
Vcc 5V  
GND GND  
SCL D1 22
SDA D2 21
INT D0 26
XDA and XCL are foreseen to control an external I2C bus, These pins are currently not used. AD0 allows to modify the MPU6050 I2C address and is also not used.

The connections of the MPU92/63 are similar

MPU92/63 !WeMos GPIO I2C SPI
Vcc 5V      
GND GND      
SCL D5 GPIO 18 SCL SCK
SDA D7 GPIO 23 SDA MOSI
AD0 D6 GPIO 19 Alternate module address MISO
INT D1 GPIO22    
NCS D0     CS
FSYNC GND      

The ADXL345 is connected as follows:

ADXL345 WeMos D1 bus GPIO
Vcc 5V  
GND GND  
SCL D1 22
SDA D2 21
INT1 D6 19
INT2 D5 18

While the MPU6050 and the ADXL345 use the I2C bus, I connected the LIS3DH to be used with the Serial Peripheral Interface (SPI) or I2C as follows:

LIS3DH SPI pins WeMos D1 bus GPIO
Vcc   3.3V  
GND   GND  
SCL SCK D5 GPIO 18
SDA MOSI D7 GPIO 23
SDO MISO D6 GPIO 19
CS CS D0 GPIO 26
INT1   D1 GPIO 22
INT2   D2 GPIO 21
ADC1   D3 GPIO 16 on ESP32 WROOM, GPIO 25 on ESP32 WROVER-B model T7 V1.5
ADC2   D4 GPIO 17 on ESP32 WROOM, GPIO 27 on ESP32 WROVER-B model T7 V1.5
ADC3   D8 GPIO 5
Remark: The LISDH breakout board has 3 SMD jumpers marked "0" on the photo above. These tie ADC channel zero and two to GND and channel one to Vcc. These jumpers must be removed if you want to use the ADC. The ADC however is of limited use as it only works in a range of ~ 800mV to 1.6V.

Providing a training data set

In order to provide a training data set, we must be able to record gestures. We must therefore provide a program that recognizes the start and the end of a gesture (movement and inactivity detection) and which records the accelerometer data of the gesture onto a file. Gesture detection is of course also needed to be able to feed the accelerometer data into the trained model, which will then recognize the gesture.

-- Uli Raich - 2022-02-02

Comments

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng adxl345.png r1 manage 173.4 K 2022-02-04 - 11:08 UliRaich  
PNGpng lis3dh.png r2 r1 manage 178.0 K 2022-02-14 - 09:08 UliRaich  
PNGpng mpu6050.png r3 r2 r1 manage 159.6 K 2022-02-04 - 11:21 UliRaich  
PNGpng mpu6050assembly.png r2 r1 manage 243.2 K 2022-02-04 - 11:24 UliRaich  
PNGpng mpu9250.png r1 manage 168.4 K 2022-05-19 - 19:48 UliRaich  
Edit | Attach | Watch | Print version | History: r12 < r11 < r10 < r9 < r8 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r12 - 2022-06-25 - UliRaich
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback