Rpi Pico HW i2c initialization problem
Hello Mike,
i am trying to initialize this with HS i2c in RPi Pico, but no success, only on SW... i have 128x128 display, with SW it works ok, but slow in samples and documentation i cannot see how to tell in code which i2c pins i am using.
import ssd1327 from machine import I2C, Pin i2c = I2C(0, scl=Pin(1), sda=Pin(0), freq=400000) display = ssd1327.SSD1327_I2C(128, 128, i2c)
with this it shows ->
Traceback (most recent call last):
File "
is there error in library, or my code... ?
Possibly related to https://github.com/mcauser/micropython-ssd1327/issues/5
According to the RP2 docs, that looks like the correct way to init HW I2C. https://docs.micropython.org/en/latest/rp2/quickref.html#hardware-i2c-bus
Maybe try reducing the freq? Or try I2C1 pins?
i2c = I2C(0, scl=Pin(1), sda=Pin(0), freq=200000)
i2c = I2C(0, scl=Pin(1), sda=Pin(0), freq=100000)
i2c = I2C(1, scl=Pin(3), sda=Pin(2), freq=400000)
i2c = I2C(1, scl=Pin(3), sda=Pin(2), freq=200000)
i2c = I2C(1, scl=Pin(3), sda=Pin(2), freq=100000)
Next time I have my Pico handy, I'll try to replicate and update the docs with a working HW I2C config.
The initialization works for other i2c device (bme280), i literally copied it from working code.
i also tried your suggestion of slower i2c / different pins, but same error occurs.
Seems there might be bug in this library, but i cannot tell for sure.
The OSError suggests the display was not found on the I2C bus.
If you perform an i2c.scan(), can you see a 60 / 0x3C?
yes, the "i2c.scan()" prints 60.
Hi @mcauser are you still working on this lib? I observed the same error. For me, your library works with SoftI2c but not with hardware I2c.
The error appears when calling i2c.writevto in
def write_data(self, data_buf): self.data_list[1] = data_buf self.i2c.writevto(self.addr, self.data_list)
Edit: Found the issue:
the TIMEDOUT error was caused by the size of the list of an 128x128 display. On the pico I measured ~205 µs for writing the list at a frequency of 400 kHz. Therefore, I had to set the I2C timeout accordingly. Now it works as expected!
Thanks for the feedback. I've been mainly using this with ESP32's. I'll do some testing with Pis before my next release.