Closed RuudKapteijn closed 11 months ago
The error means Micropython code does not receive any answer from the I2C bus. I would first double check the wiring. You could also try scanning the bus.
i2c = I2C(scl=Pin(22), sda=Pin(21))
devices = map(hex, i2c.scan())
print("I2C devices found:", end=" ")
print(", ".join(devices))
Thx for your quick answer. The i2c.scan results in an empty list/map.
I do not entirely trust the self soldered headers on the ESP32. I'll receive a pre-assembled one this week. I'll retry with that one and come back to you.
Pull-up resistors for I2C might also help. Also double check that the pins are correct just in case.
Once the right I2C pins are identified, it works fine on a pre-assembled Arduino nano ESP32.
Wiring: (ESP - MPU): 3.3V - VCC, gnd - gnd, Pin(A4) - SDA, Pin(A5) - SCL. Configuration: mpu9250.py, ak8963.py and mpu6500.py are on ESP32. No modifications to boot.py. Code:
from machine import I2C, Pin, SoftI2C
from math import sqrt, atan2, pi, copysign, sin, cos
from time import sleep
from mpu9250 import MPU9250
from lsm303d import LSM303D
# Arduino nano ESP32 pinout: https://docs.arduino.cc/hardware/nano-esp32
i2c = SoftI2C(scl=Pin(12), sda=Pin(11)) # GPIO pin 12 is A5/D22 on the board, GPIO pin 11 is A4/D21 on the board
print(f"I2C scan 1: {i2c.scan()}")
imu = MPU9250(i2c)
print("MPU9250 id: " + hex(imu.whoami))
Output:
MPY: soft reboot
I2C scan 1: [12, 104]
MPU9250 id: 0x71
Sorry for the confusion and thx for the support.
No problem. Glad it worked.
I am trying to read data from a MPU9250 from a MicroPyton program on a ESP32 WROOM.
Wiring (ESP - MPU): 3.3V - VCC, gnd - gnd, Pin(21) - SDA, Pin(22) - SCL.
Configuration: mpu9250.py, ak8963.py and mpu6500.py are on ESP32. No modifications to boot.py.
Code:
Error (on last line of code):