# MPU 9250/9255 reverse accelerometer reading

Hi guys im working with the MPU9250 Library downloaded from sparkfun im breaking my head to understand why im getting Acceleration reading which is opposite to earth surface. the mpu is mounted on a prototype matrix and from bird eye looking down: x axis pointing right (east) y axis pointing+90deg perpendicular to x axis (north) z axis pointing up (to the sky lets say)

i made sure the axis on the pcb is coherent with the mpu chip specification (small reference dot named pin 1)

and im getting a reading in z axis of 0.94mg isnt it need to be -0.94mg because the gravity acceleration direction is opposite to the positive direction of the z axis?

when i turn the pcb to point the positive x axis towards the ground i get -0.94, isnt it need to be 0.94 because its along x the axis?

and the same as y axis

i stumble in that because i noticed that im getting a negative angle in my calculation after rotating the pcb around the y positive axis (roll)

so my thought is, is the accelerometer is giving us the reading of the NORMAL to the ground surface?

thanks, drorness

Small code for the readings of the gyro and accel

``````      myIMU.readAccelData(myIMU.accelCount);  // Read the x/y/z adc values
// Now we'll calculate the accleration value into actual g's
// This depends on scale being set
myIMU.ax = (float)myIMU.accelCount[0] * myIMU.aRes - myIMU.accelBias[0];
myIMU.ay = (float)myIMU.accelCount[1] * myIMU.aRes - myIMU.accelBias[1];
myIMU.az = (float)myIMU.accelCount[2] * myIMU.aRes - myIMU.accelBias[2];

// Calculate the gyro value into actual degrees per second
// This depends on scale being set
myIMU.gx = (float)myIMU.gyroCount[0] * myIMU.gRes;
myIMU.gy = (float)myIMU.gyroCount[1] * myIMU.gRes;
myIMU.gz = (float)myIMU.gyroCount[2] * myIMU.gRes;

pitch = pitch + myIMU.gx*dt;
roll  = roll  + myIMU.gy*dt;

float G = sqrt(myIMU.ax*myIMU.ax + myIMU.ay*myIMU.ay + myIMU.az*myIMU.az);
if(G >= 0.5 && G <= 2)
{
a_roll = atan2(myIMU.ax, sqrt(myIMU.ay*myIMU.ay + myIMU.az*myIMU.az));
a_pitch  = atan2(myIMU.ay, sqrt(myIMU.ax*myIMU.ax + myIMU.az*myIMU.az));

pitch = 0.98 * pitch + 0.02 * a_pitch*RAD_TO_DEG;
roll  = 0.98 * roll  + 0.02 * a_roll*RAD_TO_DEG;
}
``````