Search code examples
pythonarduinosensorsesp32micropython

MicroPython: OSError: [Errno 19] ENODEV


I tried to connect my ESP32 to a sensor GY91(MPU9250 +BMP280). I'm using this library: https://github.com/tuupola/micropython-mpu9250

I used the example code:

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)

I imported the libraries (mpu6500,mpu9250,ak8963) to my device ESP32. But I have this error when I started the code:

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

The Sofware I use to program in MicroPython is uPyCraft, I also use Thonny. The Hardware is ESP32 and sensor GY-91 (I connected through 3 cables, Vin(of the sensor) to 5V,SCL to Pin 22 and SDA to Pin 21)

Someone could help me please


Solution

  • You said you used three wires to connect the GY-91 - VIN, SCL and SDA. You didn't mention GND.

    You must connect both GND and VIN for it to work. Use another jumper to connect GND to GND on the ESP32 and try again.

    [edit: Errno 19 ENODEV means that the module couldn't find the I2C sensor]