Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The MPU6050 example only returns 0x00 as gyro, accel and temp values #352

Open
svkers opened this issue Mar 11, 2023 · 2 comments
Open

The MPU6050 example only returns 0x00 as gyro, accel and temp values #352

svkers opened this issue Mar 11, 2023 · 2 comments

Comments

@svkers
Copy link

svkers commented Mar 11, 2023

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.

@svkers 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
@vexown
Copy link

vexown commented Mar 21, 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.

@vacoff
Copy link

vacoff commented Feb 17, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants