I am using a gyro sensor on my STM32.
SDA and SLC lines are pulled up (4.7k) and connected to I2C2 and used.
However, when accessing the address to wake up the MPU-6050 and sending endTransmission, intermittently returns 254.
When 254 is returned, 0 is returned only after unplugging and reconnecting the USB line and compiling the source.
Is there any way to solve this problem?
Code: Select all
void mpu_init() {
int rt = 0;
Wire2.beginTransmission(mpu_add);
Wire2.write(0x6B);
Wire2.write(0); // set to zero (wakes up the MPU-6050)
rt = Wire2.endTransmission(true);
Serial.println(rt); // return 254
delay(5);
}