raspberrypi / pico-examples

BSD 3-Clause "New" or "Revised" License
2.88k stars 828 forks source link

I2C MPU6050 example does not provide correct intiliazation of the device #557

Open sa2kaa opened 3 weeks ago

sa2kaa commented 3 weeks ago

Writing 80h to PWR_MGMT_1 register results in the MPU to restart in sleep mode. Instead 00h shall be written.

As shown below:

static void mpu6050_reset() {
    // Two byte reset. First byte register, second byte data
    // There are a load more options to set up the device in different ways that could be added here
//    uint8_t buf[] = {0x6B, 0x80};
    uint8_t buf[] = {0x6B, 0x00}; // Clear the SLEEP bit, do not(!) RESET the device.
      i2c_write_blocking(i2c_default, addr, buf, 2, false);
}
lurch commented 3 weeks ago

See also https://github.com/raspberrypi/pico-examples/issues?q=MPU6050