MPU6050仅在I2C上输出0x00,并使用Micropython输出
我一直在尝试使用Micropython的Pi Pico与我的MPU6050交谈。我可以验证i2c正在工作,因为在运行i2c.scan()
时,我获得了MPU6050地址(0x68)。但是,当尝试从MPU6050中读取特定寄存器时,我总是得到0x00,除了我阅读WHO_AM_I寄存器时,这只是给我字母h ???我在下面有我的代码,希望我只是一个不知道I2C的白痴,因为直到今天我才碰到它。如果有人可以帮助我,那将不胜感激!
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)
我已经提供了指向我的MPU6050 在这里,再次,任何帮助都将不胜感激!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了这个问题,我没有在PWR_MGMT_1寄存器中将睡眠略低。当它高时,它将将设备置于睡眠状态,其中没有一个寄存器返回非零值。当它的高高绑定时,它将抛出真实的价值。记住孩子们,请务必在MPU6050上咬住睡眠!
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!