Hardware I2C doesn't work on ESP32-C5
Port, board and/or hardware
esp32 port, ESP32-C5-DevKitC-1 v1.2
MicroPython version
MicroPython v1.27.0 on 2025-12-09; ESP32C5 module with ESP32C5
Reproduction
import machine
i2c0 = machine.I2C(id=0)
i2c1 = machine.I2C(id=1)
i2c0.scan()
i2c1.scan()
Expected behaviour
i2c0 and i2c1 should be created with no errors, and both should be able to scan and perform read/write operations.
Observed behaviour
Attempting to create i2c0 causes a reboot:
MicroPython v1.27.0 on 2025-12-09; ESP32C5 module with ESP32C5
Type "help()" for more information.
>>> import machine
>>> i2c0 = machine.I2C(id=0)
ESP-ROM:esp32c5-eco2-20250121
Build:Jan 21 2025
rst:0x1a (CPU_LOCKUP),boot:0x5b (SPI_FAST_FLASH_BOOT)
Core0 Saved PC:0x4200757e
SPI mode:DIO, clock div:1
load:0x408556b0,len:0xdfc
load:0x4084bba0,len:0xc4c
load:0x4084e5a0,len:0x2ee8
entry 0x4084bba0
MicroPython v1.27.0 on 2025-12-09; ESP32C5 module with ESP32C5
Type "help()" for more information.
>>>
Attempting to create i2c1 results in error messages. The I2C scan (and read/write methods) complains that the driver is not installed:
MicroPython v1.27.0 on 2025-12-09; ESP32C5 module with ESP32C5
Type "help()" for more information.
>>> import machine
>>> i2c1 = machine.I2C(id=1)
E (22747) i2c: i2c_driver_install(305): LP_I2C is not supported via i2c_driver_intall()
>>> i2c1 = machine.I2C(id=1)
E (24887) i2c: i2c_driver_delete(484): i2c driver install error
E (24887) i2c: i2c_driver_install(305): LP_I2C is not supported via i2c_driver_intall()
>>> i2c1.scan()
E (29467) i2c: i2c_master_cmd_begin(1552): i2c driver not installed
E (29467) i2c: i2c_master_cmd_begin(1552): i2c driver not installed
E (29467) i2c: i2c_master_cmd_begin(1552): i2c driver not installed
...
E (30107) i2c: i2c_master_cmd_begin(1552): i2c driver not installed
E (30107) i2c: i2c_master_cmd_begin(1552): i2c driver not installed
E (30117) i2c: i2c_master_cmd_begin(1552): i2c driver not installed
[]
>>>
Additional Information
I also noticed i2c1 (which is presumably the LP I2C peripheral) uses scl=9, sda=8:
>>> i2c1
I2C(1, scl=9, sda=8, freq=400000, timeout=50000)
However LP I2C on the ESP32-C5 can only be used on pins 2 and 3 (see the ESP32-C5 datasheet, section 4.2.1.3, "Pin Assignment").
FWIW SoftI2C() seems to work fine.
Code of Conduct
Yes, I agree
esp32c3 default I2C initializers hang the REPL.
Port, board and/or hardware
XIAO ESP32C3
MicroPython version
MicroPython v1.25.0-preview.531.gef8282c71 on 2025-04-09; XIAOC3 with ESP32C3
Reproduction
# no I2C devices attached
from machine import I2C
i2=I2C(0)
Expected behaviour
Return of valid I2C object.
Observed behaviour
REPL hangs
Additional Information
My experience with a XIAO C3 running with the GENERIC_C3 build:
MicroPython v1.25.0-preview.531.gef8282c71 on 2025-04-09; XIAOC3 with ESP32C3
is that both i2=I2C() and i2=I2C(0) hang the REPL with no return, requiring a hardware reset.
Using 1.24.1 release build, i2=I2C(0) hangs the REPL as above, but i2=I2C() fails with
Warning: I2C(-1, ...) is deprecated, use SoftI2C(...) instead
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'scl' argument required
>>> i2=I2C(0)
I will look at what is causing the hang. Note that on the XIAO S3 both i2=I2C() and i2=I2C(0) work. Maybe because there are 2 HW I2C channels available?
Code of Conduct
Yes, I agree