Adr*_*dri 4 python arduino micropython esp32 sensors
我尝试将 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)
Run Code Online (Sandbox Code Playgroud)
我将库(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, in __init__
File "mpu6500.py", line 149, in whoami
File "mpu6500.py", line 181, in _register_char
OSError: [Errno 19] ENODEV
Run Code Online (Sandbox Code Playgroud)
我用来在 MicroPython 中编程的软件是 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 传感器]