Problem using MPU-6050 on STM32F103C8T6

Post here first, or if you can't find a relevant section!
Post Reply
hyur
Posts: 36
Joined: Fri May 27, 2022 7:42 am
Answers: 2

Problem using MPU-6050 on STM32F103C8T6

Post by hyur »

hello

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); 
}
Post Reply

Return to “General discussion”