Hello,
I use the MPU6050 with an ESP8266. I have connected it to VCC, Ground, SDA, SCL of the ESP8266. When I power the board for an amount of time the MPU6050 works perfectly. However, after some moment it returns the same values no matter moving it. I first thought it was the buffer and tried emptying it at a specific amount of time. However, this made the problem appear sooner than before. After a restart of the ESP9266 board, the MPU6050 works fine again.
This is the code which I use to obtain the values from it:
in setup:
const int MPU_addr=0x68;
Wire.begin();
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
delay(10);
in loop:
Wire.beginTransmission(MPU_addr);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr,14,true);
AcX=Wire.read()<<8|Wire.read();
AcY=Wire.read()<<8|Wire.read();
AcZ=Wire.read()<<8|Wire.read();
Tmp=Wire.read()<<8|Wire.read();
GyX=Wire.read()<<8|Wire.read();
GyY=Wire.read()<<8|Wire.read();
GyZ=Wire.read()<<8|Wire.read();
//Applying a formula to turn raw values into Yaw, Pitch and Roll
int16_t roll=atan2(AcY,AcZ)*180/PI;
int16_t pitch=atan2(AcX,sqrt(AcY*AcY+AcZ*AcZ))*180/PI;
If the values that repeat are important, I can provide them. They are the same every time.
What am I doing wrong?
Thank you in advance!!!