简体   繁体   English

MPU6050 仅在 I2C 上使用 MicroPython 输出 0x00

[英]MPU6050 only outputs 0x00 on I2C with MicroPython

I've been trying to talk to my MPU6050 with a Pi Pico running MicroPython.我一直在尝试使用运行 MicroPython 的 Pi Pico 与我的 MPU6050 交谈。 I can verify the I2C is working because when running i2c.scan() , I get the MPU6050 address(0x68).我可以验证 I2C 是否正常工作,因为在运行i2c.scan()时,我得到了 MPU6050 地址(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???然而,当试图从 MPU6050 读取特定寄存器时,我总是得到 0x00,除了当我读取 WHO_AM_I 寄存器时,它只给了我字母 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.我在下面有我的代码,我希望我只是一个不知道 I2C 的白痴,因为直到今天我才接触过它。 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!我在这里提供了指向我的 MPU6050 数据表的链接,再次感谢任何帮助!

I found the issue, I did not tie the SLEEP bit low in the PWR_MGMT_1 register.我发现了问题,我没有将 PWR_MGMT_1 寄存器中的 SLEEP 位拉低。 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!记住孩子们,总是拉低 MPU6050 上的 SLEEP 位!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM