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.