MPU6050 help

Hello,
(Excuse my English, I'm french)

I got a project, a connected longboard. We using a sensors MPU6050 to get the acceleration and l'inclinaton.

We have this arduino code:

#include<Wire.h>
const int MPU_addr=0x68; // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
void setup(){
Wire.begin();
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);
Serial.begin(9600);
}
void loop(){
Wire.beginTransmission(MPU_addr);
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr,14,true); // request a total of 14 registers
AcX=Wire.read()<<8|Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
AcY=Wire.read()<<8|Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
AcZ=Wire.read()<<8|Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
Tmp=Wire.read()<<8|Wire.read(); // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
GyX=Wire.read()<<8|Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
GyY=Wire.read()<<8|Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
GyZ=Wire.read()<<8|Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
Serial.print("AcX = "); Serial.print(AcX);
Serial.print(" | AcY = "); Serial.print(AcY);
Serial.print(" | AcZ = "); Serial.print(AcZ);
Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53); //equation for temperature in degrees C from datasheet
Serial.print(" | GyX = "); Serial.print(GyX);
Serial.print(" | GyY = "); Serial.print(GyY);
Serial.print(" | GyZ = "); Serial.println(GyZ);
delay(2000);
}

We get the following values: (you that moving the MPU):

AcX = 740 | AcY = 44 | AcZ = 17928 | Tmp = 25.42 | GyX = -388 | GyY = -147 | GyZ = 122
AcX = 632 | AcY = 32 | AcZ = 17788 | Tmp = 25.38 | GyX = -410 | GyY = -141 | GyZ = 180
AcX = 576 | AcY = 164 | AcZ = 17916 | Tmp = 25.33 | GyX = -392 | GyY = -163 | GyZ = 161
AcX = 612 | AcY = 84 | AcZ = 17796 | Tmp = 25.28 | GyX = -389 | GyY = -167 | GyZ = 174
AcX = 792 | AcY = 76 | AcZ = 17796 | Tmp = 25.24 | GyX = -387 | GyY = -167 | GyZ = 187
AcX = 564 | AcY = -16 | AcZ = 17624 | Tmp = 25.24 | GyX = -413 | GyY = -162 | GyZ = 171
AcX = 696 | AcY = 4 | AcZ = 17764 | Tmp = 25.28 | GyX = -372 | GyY = -170 | GyZ = 177
AcX = 700 | AcY = -28 | AcZ = 17732 | Tmp = 25.19 | GyX = -405 | GyY = -177 | GyZ = 137
AcX = 680 | AcY = 64 | AcZ = 17824 | Tmp = 25.09 | GyX = -382 | GyY = -183 | GyZ = 148

I think the values are strange. I calculated the addition. I calculated the standards for each axis and I have this values : 17 000 to 18000.
In accordance with the documentation, the units is the mg (milligal). I found when converting, 0,17677 m/s². I don't understand why a have this values. I'm supposed to have 9.81m/s² (acceleration of the earth).

I've been looking for hours the problems but I don't find.
Help me please.

Thank you for your help.

If you look at page 12 of the datasheet, in the first section, it states the range of values that the accelerometer output represents: +- 2g
And the output value that represents 1g is 16384
(These are both at the default AFS_SEL setting of 0)

To convert your raw values into g, you can simply divide by the value for 1g, so for the first line of your ouput:
X = 740/16384 = 0.045g
Y = 44/16384 = 0.003g
Z = 17928/16384 = 1.094g

This is roughly what you would expect to see with the chip level - X and Y are 0g, and Z is 1g.
I'm not sure where your figure of 0.17677 is coming from.

You can do the same with the gyro values, divide by 131 to get the value in degrees per second.

Your sensor will probably have some offset to its values which you need to compensate for. For the gyros you can take the average of a large number of readings while it is not moving. For the accelerometer you can do the same while it is level (use a spirit level). Use the difference between your average and the expected value, 0 (or 16384 for accel Z axis) to correct the raw values.

Note that to calculate the inclination from the accelerometer, you can just use the raw values (corrected for offset) directly because it is the relative values that determine the angle, not the absolute values.

Thank you for your help.

I found the solution. It's coherent.

Thank for your answer.