has anyone been able to get I2C running on RP2040? From what I’ve read it should work. If I add an I2C bus definition (with or without sensor definition) my Pico W does not boot anymore. Not even a log appears. If I uncomment it, it boots.
Hi, I also have troubles getting I2C on my Pico W to work with ESPhome.
First of all, I found some information that only the I2C0 hardware is usable:
I have connected 4k7 pull-ups to GPIO4 & GPIO5 (I2C0), but I always get an error: Recovery: failed, SDA is held low on the bus
Using my Multimeter I can measure stable 3.3V on both pins.
@emefff could resolve the issues by using the GPIO numbers for pin 21 & 20.
When using these GPIOs, I also measure 3.3V on these pins (i.e. internal pull-ups are activated successfully), but I also have the same issue regarding “SDA is held low”
I tried multiple pin-pairs of the i2c0 peripheral and 3 different pico boards in total, no external components are connected on the i2c bus, beside the pull-up resistors on GPIO4 & GPIO5.
Does anyone have a clue why I am getting these errors?
ESPHome version 2024.7.1
Configuration (additional to default config for Pi Pico W):
i2c:
sda: GPIO20
scl: GPIO21
scan: true
id: bus_a
ESPHome log:
17:28:50][I][app:100]: ESPHome version 2024.7.1 compiled on Jul 23 2024, 17:19:07
[17:28:50][C][wifi:599]: WiFi:
[17:28:50][C][wifi:427]: Local MAC: D8:3A:DD:21:C3:F8
[17:28:50][C][wifi:432]: SSID: [redacted]
[17:28:50][C][wifi:435]: IP Address: 10.69.1.201
[17:28:50][C][wifi:438]: BSSID: [redacted]
[17:28:50][C][wifi:440]: Hostname: 'test-aqm'
[17:28:50][C][wifi:442]: Signal strength: -37 dB ▂▄▆█
[17:28:50][C][wifi:446]: Channel: 6
[17:28:50][C][wifi:447]: Subnet: 255.255.0.0
[17:28:50][C][wifi:448]: Gateway: 10.69.0.1
[17:28:50][C][wifi:449]: DNS1: 10.69.0.1
[17:28:50][C][wifi:450]: DNS2: 0.0.0.0
[17:28:50][C][logger:185]: Logger:
[17:28:50][C][logger:186]: Level: DEBUG
[17:28:50][C][logger:188]: Log Baud Rate: 115200
[17:28:50][C][logger:189]: Hardware UART: USB_CDC
[17:28:50][C][i2c.arduino:071]: I2C Bus:
[17:28:50][C][i2c.arduino:072]: SDA Pin: GPIO20
[17:28:50][C][i2c.arduino:073]: SCL Pin: GPIO21
[17:28:50][C][i2c.arduino:074]: Frequency: 50000 Hz
[17:28:50][C][i2c.arduino:092]: Recovery: failed, SDA is held low on the bus
[17:28:50][I][i2c.arduino:096]: Results from i2c bus scan:
[17:28:50][I][i2c.arduino:098]: Found no i2c devices!
[17:28:50][C][mdns:116]: mDNS:
[17:28:50][C][mdns:117]: Hostname: test-aqm
[17:28:50][C][esphome.ota:073]: Over-The-Air updates:
[17:28:50][C][esphome.ota:074]: Address: test-aqm.local:2040
[17:28:50][C][esphome.ota:075]: Version: 2
[17:28:50][C][esphome.ota:078]: Password configured
[17:28:50][C][safe_mode:018]: Safe Mode:
[17:28:50][C][safe_mode:019]: Boot considered successful after 60 seconds
[17:28:50][C][safe_mode:021]: Invoke after 10 boot attempts
[17:28:50][C][safe_mode:022]: Remain in safe mode for 300 seconds
[17:28:50][W][safe_mode:028]: Last reset occurred too quickly; safe mode will be invoked in 8 restarts
[17:28:50][C][api:139]: API Server:
[17:28:50][C][api:140]: Address: test-aqm.local:6053
[17:28:50][C][api:142]: Using noise encryption: YES
I have to admit: the reason my I2C device did not work was that I mixed up the SCL & SDA lines while connecting the device
… however, the log output regarding SDA is held low then brought my attention away from the connected device to getting rid of this log message by not connecting any device to the pi pico.
Turns out, when connecting a I2C device (correctly) to the pico, this log line is always produced wrongfully, although the I2C devices are working (and also the address scan is working).