如何解决MicroPython:OSError:[Errno 19] ENODEV
我试图将ESP32连接到传感器GY91(MPU9250 + BMP280)。 我正在使用此库:https://github.com/tuupola/micropython-mpu9250
我使用了示例代码:
import utime
from machine import I2C,Pin
from mpu9250 import MPU9250
i2c = I2C(scl=Pin(22),sda=Pin(21))
sensor = MPU9250(i2c)
print("MPU9250 id: " + hex(sensor.whoami))
while True:
print(sensor.acceleration)
print(sensor.gyro)
print(sensor.magnetic)
print(sensor.temperature)
utime.sleep_ms(1000)
我将库(mpu6500,mpu9250,ak8963)导入了我的设备ESP32。 但是在启动代码时出现此错误:
Traceback (most recent call last):
File "<stdin>",line 1,in <module>
File "<string>",line 8,in <module>
File "mpu9250.py",line 45,in __init__
File "mpu6500.py",line 97,line 149,in whoami
File "mpu6500.py",line 181,in _register_char
OSError: [Errno 19] ENODEV
我用来在MicroPython中编程的Sofware是uPyCraft,我也使用Thonny。 硬件为ESP32和传感器GY-91(我通过3条电缆连接,传感器的Vin接5V,SCL接22针,SDA接21针)
有人可以帮助我
解决方法
您说过,您使用三根线连接GY-91-VIN,SCL和SDA。您没有提到GND。
您必须同时连接GND和VIN才能正常工作。使用另一个跳线将GND连接到ESP32上的GND,然后重试。
[编辑:Errno 19 ENODEV表示模块找不到I2C传感器]
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。