Hello, I have received my UDOO KEY, I try to read ICM-20948 sensor via I2C form both microcontroller (RP and XX) with Micropython. When I try to query the sensor on the I2C bus by requesting the device ID, I always get an unexpected value (see attached image). I can't read the sensor register properly. where am i wrong? Saluti
Notice that, only for kickstarters, the IMU sensor has been changed and is currently installed the model MPU-6500, a 6-axis motion tracking sensor. This notice is in the docs. Different sensor entirely. Maybe this is causing your issue.
Thank you! I missed the notice,I was referring to the schematics! Now it work, the right sensor is MPU6500
Just adding some extra information for if you want to talk to it on the 2040: from machine import Pin, I2C from time import sleep bus = I2C(1, scl=Pin(3), sda=Pin(2), freq=400000) print(bus.scan()) print(bus.readfrom_mem(105, 117, 1)) This will return both the I2C address (105 decimal, aka 0x69 hex) and the WHOAMI info ( b'p' or 0x70 hex) to confirm the MPU6500. P4 (labelled as I2C) on the board will need to have pins 1 and 2 jumpered (the dot will indicate Pin 1).
Hi, when I try this I get an error: >>> from machine import Pin, I2C >>> bus = I2C(1, scl=Pin(3), sda=Pin(2), freq=400000) >>> print(bus.scan()) [105] >>> print(bus.readfrom_mem(105, 117, 1)) Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: [Errno 5] EIO Any idea what could be going wrong? I have a jumper connected to pins 1 and 2 of the P4 jumper (labeled I2C).
UPDATE: Accessing the MPU6500 from the ESP32 with the standard I2C micropython library works perfectly, but I have to use the SoftI2C micropython library for it to work on the RP2040. On ESP32: >>> from machine import Pin, I2C >>> bus = I2C(1, scl=Pin(21), sda=Pin(18), freq=400000) >>> print(bus.scan()) [105] >>> print(bus.readfrom_mem(105, 117, 1)) b'p' So there is nothing wrong with I2C on the ESP32, and nothing wrong at all with the MPU6500 module. I tried re-flashing the latest stable micropython firmware on RP2040 (v1.20), and even tried flashing the latest micropython nightly build for Rpi Pico, but I still got the same error as before trying to read from the MPU6500 using the RP2040. Finally, I tried using the SoftI2C micropython library on the RP2040, which does NOT use the native I2C hardware, and this worked. On RP2040: >>> from machine import Pin, SoftI2C >>> bus = SoftI2C(scl=Pin(3), sda=Pin(2), freq=400000) >>> print(bus.scan()) [105] >>> print(bus.readfrom_mem(105, 117, 1)) b'p' So, apparently something is wrong with the hardware supporting I2C on RP2040. I guess I can just use SoftI2C, but this puts the burden of I2C on the RP2040 processor. Any thoughts on anything else to try here?
I'm using Arduino IDE, but am struggling with the same problem. After I found a working library for the sensor, it was pretty straightforward to get the sensor data output with the ESP32. But I haven't yet found a way to get this to work with the RP2040. But then again, I have no prior experience with the RP2040
Fortunately I have been able to communicate with the MPU using the methods described above, but I have a question. What does the I2C peripheral ID value of 1 in the micropython I2C() function represent? Does it indicate which I2C bus is being used? I can't find this ID documented anywhere nor have I been able to puzzle it our from the Udoo Key schematics or the MPU6500 docs. I'd really like to know!