Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get actual g-force values? #747

Open
BJPatriotRacing opened this issue May 22, 2023 · 0 comments
Open

How to get actual g-force values? #747

BJPatriotRacing opened this issue May 22, 2023 · 0 comments

Comments

@BJPatriotRacing
Copy link

Thanks for the library, it's very complete.

I'm using a Teensy 4.0 with normal and working connections. The unit seems to be working fine and reporting data with the MPU6050_raw example.

I'm looking at the value for getAccelerationZ and it's reporting 16072 (unit z is pointing up). If I smack the unit i can get a max of just over 32000--This makes sense since the datatype is an int16.

However, how do I get g force? If 16,384 is 1 g, then this unit can only report up to 2 g's (accel/16384).

Here's my code.

#include "I2Cdev.h"
#include "MPU6050.h"
#include "Wire.h"

MPU6050 accelgyro;

int16_t ax, ay, az;
int16_t gx, gy, gz;

elapsedMillis Timer;

void setup() {

Wire.begin();

Serial.begin(38400);

accelgyro.initialize();

accelgyro.setFullScaleGyroRange((MPU6050_IMU::MPU6050_GYRO_FS_1000));
accelgyro.setFullScaleAccelRange((MPU6050_IMU::MPU6050_ACCEL_FS_16));

//accelgyro.CalibrateGyro(); // Fine tune after setting offsets with less Loops.
//accelgyro.CalibrateAccel(); // Fine tune after setting offsets with less Loops.
}

void loop() {

Serial.print(accelgyro.getAccelerationX());
Serial.print(",");
Serial.print(accelgyro.getAccelerationY());
Serial.print(",");
Serial.println(accelgyro.getAccelerationZ());
delay(10);
}

Thoughs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant