rfetick / MPU6050_light

Lightweight, fast and simple library to communicate with the MPU6050
MIT License
131 stars 38 forks source link

Angle Z drifting #40

Open ImVictorYT opened 1 year ago

ImVictorYT commented 1 year ago

sometimes the angle z keeps increasing with out movemnt

cemyasam2 commented 1 year ago

sometimes the angle z keeps increasing with out movemnt Find the following line in the MPU6050_light.cpp file

  accX = ((float)rawData[0]) / ACC_LSB_2_G;
  accY = ((float)rawData[1]) / ACC_LSB_2_G;
  accZ = ((float)rawData[2]) / ACC_LSB_2_G;
  temp = (rawData[3] + TEMP_LSB_OFFSET) / TEMP_LSB_2_DEGREE;
  gyroX = ((float)rawData[4]) / GYRO_LSB_2_DEGSEC - gyroXoffset;
  gyroY = ((float)rawData[5]) / GYRO_LSB_2_DEGSEC - gyroYoffset;
  gyroZ = ((float)rawData[6]) / GYRO_LSB_2_DEGSEC - gyroZoffset;

Please add the line below

if(gyroZ>-0.4 && gyroZ<0.4) {gyroZ=0;}