I had quite some trouble getting my MPU6050's to work.
As it turns out they start with the PWR_MGMT_1_REG set as 0x40 (everything zero, reset flag 1), which doesn't result in a working chip if you try to overwrite it with zeros.
What ended up working for me is first writing 0xFF to the PWR_MGMT_1_REG and subsequently writing the zeroes.
I'm not sure if I just had a batch of dud MPU6050's that way, or of this is going to be a common problem, but this is my request to add the line of code to the initialization function. :)
(MPU6050.c Line 77-78)
// power management register 0X6B we should write all 0's to wake the sensor up
Data = 0;
HAL_I2C_Mem_Write(I2Cx, MPU6050_ADDR, PWR_MGMT_1_REG, 1, &Data, 1, i2c_timeout);
to:
// power management register 0X6B we should write all 0's to wake the sensor up
Data = 0xFF;
HAL_I2C_Mem_Write(I2Cx, MPU6050_ADDR, PWR_MGMT_1_REG, 1, &Data, 1, i2c_timeout);
Data = 0x00;
HAL_I2C_Mem_Write(I2Cx, MPU6050_ADDR, PWR_MGMT_1_REG, 1, &Data, 1, i2c_timeout);
I had quite some trouble getting my MPU6050's to work. As it turns out they start with the PWR_MGMT_1_REG set as 0x40 (everything zero, reset flag 1), which doesn't result in a working chip if you try to overwrite it with zeros. What ended up working for me is first writing 0xFF to the PWR_MGMT_1_REG and subsequently writing the zeroes.
I'm not sure if I just had a batch of dud MPU6050's that way, or of this is going to be a common problem, but this is my request to add the line of code to the initialization function. :)
(MPU6050.c Line 77-78)
to: