Description
The provided example for the MPU6050 does not work as expacted: It only returns 0x00 instead of the real gyro, accel and temp values.
After struggeling several time I finally managed to get real values from the MPU6050 by changing the following code line:
``` 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}; i2c_write_blocking(i2c_default, addr, buf, 2, false); } ```
to
``` 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, 0x00}; i2c_write_blocking(i2c_default, addr, buf, 2, false); } ```
The MPU-6500 Register Map and Descriptions Revision 2.1 states that register 0x6B is the PWR_MGMT_1 register:
DEVICE_RESET SLEEP CYCLE GYRO_STANDBY TEMP_DIS CLKSEL[2:0]
So setting this register to 0x80 (binary: 1000 0000) means that the bit DEVICE_RESET is set to 1 whereas all other bits are set to 0.
The document also states for this register and bit the following:
DEVICE_RESET 1 – Reset the internal registers and restores the default settings. Write a 1 to set the reset, the bit will auto clear.
Since I am quite new to Pico and electronics I would be really glad for further clarification. Thanks!
Note: I faced this issue with various MPU6050 boards that I tested.