When I saw the track for Sci-Fi movies, I was so excited. Growing up on movies like 2001: A Space Odyssey, Gattaca, and Black Mirror episodes, I wanted to create something that I would see in these movies. Now, of course I would not be able to create a flying machine or something, I wanted to make something you could find in a cutscene. An often cutscene in these movies involve the protagonists training or working out. From there, I began to think about things I would see in the future for gyms. With the pandemic, many people had to start working from home. This caused a boom in at-home workouts, as those people were uncomfortable/unable to access a public gym. This caused so many new and inexperienced people with their dumbbells. I was one of those people, and I had developed a bad habit of incorrect form, to which I only corrected when returning to a public gym. So, I decided to create BreakBE to help fix this common problem. This could be seen in Sci-Fi movies, with futuristic devices helping people work out.

What it does

BreakBE is a device that uses an Arduino UNO and an accelerometer (MPU6050) to track the acceleration of a dumbbell during a bicep curl. The raw data is then sent to a MATLAB script to be cleaned and plotted. Accelerometers are able to detect position, but only relative to position (see "Challenges I ran into") in both the x and y directions. When a person does a bicep curl correctly, acceleration in both the x and y directions are rather small and thus the positions won't change much. Bad form, however, is when a person uses momentum to lift a weight. In order to create this momentum, this person must accelerate heavily in the y-direction. So, the MATLAB script plots the (x,y) from the accelerometer and stops recording when the position from the y-direction surpasses a threshold of 5 units.

How I built it

To begin, it is necessary to collect the MPU6050 data. I used the Electronic Cat's library example which allowed me to collect the raw data from the sensor and submit it through the serial monitor as seen in the mpu.ino (arduino) file below (full program can be found in my github repository, at the bottom:

Serial.print(gx); Serial.print("\t");
Serial.print(", ");
Serial.print(gy); Serial.println("\t");

Once the device submits data into the serial monitor, we collect it in the MATLAB script:

s = serialport('COM7',115200); 
a = fscanf(s);

b = convertCharsToStrings(a);
b = regexprep(b, '\s+', ''); %remove spaces
x = extractBefore(b,','); %create string of x data before the comma, since raw data is in format (x,y)
y = extractAfter(b,','); %create string of y data after the comma, since raw data is in format (x,y)
x = str2double(x); 
y = str2double(y);

After that, we plot the data as a scatter plot connected by lines with a horizontal line to indicate threshold

    yline(5,'-.r'); %constant horizontal line to show threshold

    %Stop and show bad form text when the y passes 5 (below)
    if yinters > 0
        text((max(datax)-100),(max(datay)-0.5),'BAD FORM!!');

Find when y > 5

%threshold detected
    if y > 5
        yinters = datay(datay==y);
        xinters = datax(datay==y);

And that's all!

Challenges I ran into

Problem 1 I originally completely miss understood how the MPU6050 works. Originally, I thought that it was able to record position, as in if I held the device in one spot, then it could constantly give the position of the device relative to the starting point. However, this does not work. The (x,y) data from the device gives the position relative to the acceleration. If I hold it still, then move it, it will give me the (x,y) from that starting point. But once it becomes still again, the data goes back to (0,0). So, I had to improvise and detect when the acceleration gets too large in the y-direction.

Problem 2 I originally wanted to use an ESP32, for wireless data transmission to the computer so I won't be limited by the distance of my wires. However, my ESP32 was broken, outputting a voltage of only 0.8V which could not power the MPU6050.

Accomplishments that I'm proud of

I am simply proud of what I made. I ran into many problems, and I am glad I was able to overcome them by finding a more clever way to solve them.

What I learned

I learned how accelerometer actually work, and I learned how to real serial data with MATLAB

What's next for BreakBE (Break Bad Exercise)

Use an ESP32 for wireless data transmission, so I won't accidentally rip the wires apart when working out. Additionally, I would like to create 3D printed chassis for the MPU6050, rather than simply screw it on the side of the dumbbell.

Built With

Share this project: