You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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);
}
```
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.
The text was updated successfully, but these errors were encountered:
svkers
changed the title
The Pico i2c C example for the MPU6050 only returns 0x00 as gyro, accel and temp values
The MPU6050 example only returns 0x00 as gyro, accel and temp values
Mar 11, 2023
Hi @svkers, I added a clarification of this solution if you want to understand what is going on with this. Check out the #319 for my comment if you're interested.
Man I can't tell you how much time I wasted on this topic. I didn't ever think the implementation could be the source of the problem. I spent 6 days in span of 3 months try to get reading from 3 different sensors, the last one which I ordered new try to narrow down the problem.
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:
to
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.
The text was updated successfully, but these errors were encountered: