Trouble when moving IMUAccelerometer (MPU6500)

Hi together,

actually I am experimenting with an accelerometer an gyroscope of MPU6500.
I am able to read angluar velocity in LSB/°/s from I2C with the following code:

#include<Wire.h>


const int mpu_addr = 0x68;
void setup()
{
  Wire.begin();
  Wire.setClock(400000UL); // Set I2C frequency to 400kHz
  Wire.beginTransmission(mpu_addr);
  Wire.write(0x6B);
  Wire.write(0); // wake up the mpu6050
  Wire.endTransmission(true);
  Serial.begin(9600);
}
void loop() {            
  int16_t gx_LSBs = Acc_X();
  int16_t gy_LSBs = Acc_Y();
  int16_t gz_LSBs = Acc_Z();

  double gx = (double)1/16384*gx_LSBs;  
  double gy = (double)1/16384*gy_LSBs;
  double gz = (double)1/16384*gz_LSBs;

  int16_t wx_LSBs = Gyro_X();
  int16_t wy_LSBs = Gyro_Y();
  int16_t wz_LSBs = Gyro_Z();

  //delay(500);
 
  Serial.print("gx:   ");
  Serial.print(gx);
  Serial.print("      gy:   ");
  Serial.print(gy);
  Serial.print("      gz:   ");
  Serial.print(gz);
  Serial.print("              ");
  
  Serial.print("wx:   ");
  Serial.print(wx_LSBs);
  Serial.print("      wy:   ");
  Serial.print(wy_LSBs);
  Serial.print("      wz:   ");
  Serial.print(wz_LSBs);
  Serial.println("");

  
}

// Funktionen Gyroskop
int16_t Gyro_X()
{
  Wire.beginTransmission(mpu_addr);
  Wire.write(0x43);
  Wire.endTransmission(false);
  Wire.requestFrom(mpu_addr,2);
  int16_t GyroX = Wire.read()<<8|Wire.read();
  Wire.endTransmission(true);
  return GyroX;
}

int16_t Gyro_Y()
{
  Wire.beginTransmission(mpu_addr);
  Wire.write(0x45);
  Wire.endTransmission(false);
  Wire.requestFrom(mpu_addr,2);
  int16_t GyroY = Wire.read();
  GyroY = GyroY<<8|Wire.read();
  Wire.endTransmission(true);
  return GyroY;
}

int16_t Gyro_Z()
{
  Wire.beginTransmission(mpu_addr);
  Wire.write(0x47);
  Wire.endTransmission(false);
  Wire.requestFrom(mpu_addr,2);
  int16_t GyroZ = Wire.read()<<8|Wire.read();
  Wire.endTransmission(true);
  return GyroZ;
}


// Funktionen Accelerometer
double Acc_X()
{
  Wire.beginTransmission(mpu_addr);
  Wire.write(0x3B);
  Wire.endTransmission(false);
  Wire.requestFrom(mpu_addr,2);
  int16_t AccX=Wire.read()<<8|Wire.read();  // zweimaliges Lesen des I2C
  Wire.endTransmission(true);
  return AccX;
}

double Acc_Y()
{
  Wire.beginTransmission(mpu_addr);
  Wire.write(0x3D);
  Wire.endTransmission(false);
  Wire.requestFrom(mpu_addr,2);
  int16_t AccY=Wire.read()<<8|Wire.read();
  Wire.endTransmission(true);

  return AccY;  
}

double Acc_Z()
{
  Wire.beginTransmission(mpu_addr);
  Wire.write(0x3F);
  Wire.endTransmission(false);
  Wire.requestFrom(mpu_addr,2);
  int16_t AccZ=Wire.read()<<8|Wire.read();
  Wire.endTransmission(true);

  return AccZ;  
}

I am just wondering that very often the output is getting interrupted and result is:

gx: 0.05 gy: 0.07 gz: 1.00 wx: -25 wy: -122 wz: -53
gx: 0.05 gy: 0.07 gz: 1.01 wx: 2 wy: -115 wz: -64
gx: 0.05 gy: 0.07 gz: 1.01 wx: 2 wy: -82 wz: -79
gx: 0.05 gy: 0.07 gz: 1.01 wx: -23 wy: -113 wz: -77
gx: 0.05 gy: 0.07 gz: 1.00 wx: -16 wy: -114 wz: -72
gx: 0.05 gy: 0.07 gz: 1.01 wx: -51 wy: -142 wz: -75
gx: -0.00 gy: -0.00 gz: -0.00 wx: -1 wy: -1 wz: -1
gx: -0.00 gy: -0.00 gz: -0.00 wx: -1 wy: -1 wz: -1
gx: -0.00 gy: -0.00 gz: -0.00 wx: -1 wy: -1 wz: -1
gx: -0.00 gy: -0.00 gz: -0.00 wx: -1 wy: -1 wz: -1
gx: -0.00 gy: -0.00 gz: -0.00 wx: -1 wy: -1 wz: -1

Anyone having an idead of the reason for the problem?
Especially when moving the IMU output shows me wx=wz=wy = -1.
I can’t imagine but is there maybe an overflow or another behaviour that explains this output?

Thanks a lot!

I can't imagine but is there maybe an overflow or another behaviour that explains this output?

Most probably a wiring failure. Either a broken wire, bad breadboard contact or too long wires.

Have you considered asking the mpu if it has new data ready before asking for a data read?

For testing try to set up using the mpu interrupt pin to trigger a data read when the mpu has data to see if you are still losing data. After making sure the wiring is not wonky.

I will configure the INT-Pin and try again.
I figured out that the error occures right after touching the mpu or moving it from the table.
Maybe there is an capacitive error?

Couldn´t find some information in the datahseet or the register map about the previous mentioned behaviour.
Does some of you know if there is a pin on imu that distrubes dataoutput when getting high or low?
Could the INT-Pin be the reason for these problem?

Thanks so far!!!

I guess I figured out the problem.
AD0 pin is not connected.
If AD0 is getting high, I2C adress is changing from 0x68 to 0x69.