I'm following along with this tutorial and library https://learn.adafruit.com/adafruit-mma ... g-and-test. It works as described, but I think something is wrong.
I believe (and Wikipedia confirms) that the acceleration due to gravity is 9.8 m/s^2 not 0.98 m/s^2. The library example, true to the tutorial, does produce 0.98 though. I dug in and if I replace the lines:Example for line 2:
X: -0.07 Y: 0.09 Z: 0.98 m/s^2
Serial.print("X: \t"); Serial.print(event.acceleration.x); Serial.print("\t");
Serial.print("Y: \t"); Serial.print(event.acceleration.y); Serial.print("\t");
Serial.print("Z: \t"); Serial.print(event.acceleration.z); Serial.print("\t");
with...
Serial.print("X: \t"); Serial.print(mma.x_g * (SENSORS_GRAVITY_STANDARD)); Serial.print("\t");
Serial.print("Y: \t"); Serial.print(mma.y_g * (SENSORS_GRAVITY_STANDARD)); Serial.print("\t");
Serial.print("Z: \t"); Serial.print(mma.z_g * (SENSORS_GRAVITY_STANDARD)); Serial.print("\t");
It comes out right... but that looks like pretty much exactly what is being done in the library internally. Nevertheless, it is coming out of the library differently than if I put the conversion in the sketch directly. I'm compiling in Arduino 1.6.9 on Ubuntu 14.04 if that matters. I traced through the library and nothing jumped out at me as obviously wrong, but there is something nuanced going wrong I'm pretty sure.
I brought it here instead of putting an issue on Git-Hub in accordance with the request on the GitHub issue template. What say you?