DIY a Simple Three-axis Accelerometer Data Logger

by Jaychouu in Circuits > Arduino

539 Views, 2 Favorites, 0 Comments

DIY a Simple Three-axis Accelerometer Data Logger

效果图.png
QQ图片20230220093029.png
封面.png
ezgif.com-optimize (1).gif
How SPI Protocol Works

Story

Background

ChatGPT has gained immense popularity recently, and the system has even been down due to a significant surge in usage. This aroused my interest in Machine Learning. I learned that TinyML enables the deployment of ML models on edge devices with limited resources, such as MCUs. So I decided to explore it by embarking on a simple project.

Thought

The first step is to collect and store data for future model training on TinyML. I just got an accelerometer+gyroscope module, so I plan to make a simple data logger, which will gather and save the three-axis (x, y, and z) data of hand movements to a microSD card and display them on an OLED screen in real-time.

Supplies

QQ图片20230215142850.png

Connection Diagram

电路图英2.png

ESP32-E to Accel+Gyro Module

3.3V to 3.3V

GND to GND

SCK to SCK

MI to SDI

MO to SDO

D12 to CS

ESP32-E to MicroSD card reader

5V to 5V

GND to GND

MO to MO

D6 to SS

SCK to SCK

MI to MI

ESP32-E to 0.96" OLED display

3.3V to 3.3V

GND to GND

D5 to SCL

D7 to SDA

D2 to D/C

D10 to CS

Housing Design

QQ图片20230217104917.jpg
ezgif.com-optimize (4).gif
1.png
QQ图片20230217110918.jpg
QQ图片20230215143828.png

To build the 3D model of the housing, we need to design the hardware layout and measure dimensions first, then draw the model on SolidWorks.

The housing of the data recorder includes a cover, base, and main body(box without a top).

Meanwhile, we need to reserve the Type-C port, switch and SD card slots, and 4 holes for M2 screws on the housing.

Then slice and print the 3D model.

Solder Hardware

QQ图片20230215162716.png
QQ图片20230215162703.png
QQ图片20230215163605.png
QQ图片20230215162711.png
QQ图片20230215145254.png
QQ图片20230216112132.jpg
QQ图片20230216105617.jpg

The ESP32-E IoT MicrocontrollerICG 20660L Accel+Gyro 6-Axis IMU ModuleMicroSD card reader, and 0.96" OLED display need to be soldered according to the connection diagram.

The OLED display uses I2C for communication by default, and here we need to change the position of the resistor to use SPI.

Then connect the battery and switch to the ESP32 main controller.

Assembly

QQ图片20230216105613.jpg
QQ图片20230216105617.jpg
QQ图片20230216110246.jpg
QQ图片20230216105737.jpg
QQ图片20230216105610.jpg
QQ图片20230216105626.jpg
QQ图片20230216105622.jpg
QQ图片20230216105601.jpg
ezgif.com-optimize (2).gif

For the sake of convenience, I design a base that allows the whole device to be fixed onto the arm with a strap. And the main body box is connected to the base by magnetic adsorption.

1. Embed two magnets into the base, install another two on the corresponding position of the box bottom, and fix them with hot glue. Then they can attract each other.

2. Fix the battery on the bottom of the box using double-sided tape, and then fix the main controller on the battery with the Type-C port aligned with the reserved slot.

3. Install the switch with hot glue.

4. Fix the display, SD memory card, and acceleration module to the cover plate.

5. Finally, put the cover on and screw to fix it.

6. The effect display is shown in the figure above.

Upload Program

QQ图片20230217135344.png

Then upload the program. 

In the program, the three-axis values are recorded and saved to the MicroSD card and displayed on the LCD in real time.

Data Collection

QQ图片20230215162657.png
ezgif.com-optimize (3).gif
fecb870a8bd70263743a4991b20cb7a8.png
eda1de07fad4b5a6806b762cbb19e782.png

1. Insert the MicroSD memory card into the corresponding slot to store data.

The main body can be attached to the base easily.

2. Power on the device, and record different movement trajectories such as square, triangle, circle, and cross (or X).

3. And read the data in CSV format from the MicroSD memory card.

I just simply test the device by gathering hand movement data. It can also be used to measure the g-forces exerted on your body when you do your favorite sports.

I will continue to try using the data for TinyML training and generate a neural network model.

Thanks for reading, feel free to leave your opinion about this project.