Hi any help is appreciated,
I have my GY 512 accelerometer wired up and code written for producing raw values given by the accelerometer to the serial monitor. I am wondering how to code it so that the numbers displayed reflect acceleration in m/s^2 instead of the raw values. To further clarify what I am trying to do, I want to attach the accelerometer to an object and want to know the acceleration of this object as it moves.
Thank you!
If you hold the accelerometer still, with one axis vertical, the raw units displayed for that axis correspond to 1 g. Use that as a scale factor.
There will be a separate offset and scale factor for each axis, so if you are concerned about accuracy, you will want to calibrate the accelerometer. There are many tutorials on line showing how.
I know that I should just multiply the raw value (in g) by gravity, but I am wondering what function/equation in the programing I would use for doing so. I do plan on calibrating it and have a tutorial pinned thank you.
Division works. For the x-axis you might do something like this, although there is probably an offset that should be subracted.
float acc_x_in_g = (float) raw_acc_x / (float) raw_observed_1g_x;
If you want m/s^2, multiply the result by 9.81.
float acc_x_in_ms2 = acc_x_in_g*9.81;
Okay great thanks! Ill try that out.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.