MPU6050 only outputs 0x00 on I2C with MicroPython

Viewed 171

I've been trying to talk to my MPU6050 with a Pi Pico running MicroPython. I can verify the I2C is working because when running i2c.scan(), I get the MPU6050 address(0x68). However, when trying to read a specific register from the MPU6050, I always get 0x00, except for when I read the WHO_AM_I register, which just gives me the letter h??? I have my code below, I hope I'm just being an idiot that doesn't know I2C, because I've never even touched it until today. If anybody can help me, it would be greatly appreciated!

import machine

sda = machine.Pin(4)
scl = machine.Pin(5)
i2c = machine.I2C(0, sda = sda, scl = scl)

i2c.writeto(0x68, b'\x42') # Read the TEMP_OUT_L register
gyro = i2c.readfrom(0x68, 1)

print(gyro)

I've provided a link to the datasheet of my MPU6050 right here, again, any help would be appreciated!

1 Answers

I found the issue, I did not tie the SLEEP bit low in the PWR_MGMT_1 register. When it's high, it will put the device into a sleeping state, where none of the registers return non-zero values. When its tied high, it will throw real values. Remember kids, always pull down the SLEEP bit on your MPU6050!

Related