Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rpi Pico HW i2c initialization problem #6

Open
dingo27mobile opened this issue Aug 15, 2023 · 6 comments
Open

Rpi Pico HW i2c initialization problem #6

dingo27mobile opened this issue Aug 15, 2023 · 6 comments

Comments

@dingo27mobile
Copy link

dingo27mobile commented Aug 15, 2023

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 "", line 4, in
File "ssd1327.py", line 178, in init
File "ssd1327.py", line 78, in init
File "ssd1327.py", line 113, in init_display
File "ssd1327.py", line 186, in write_data
OSError: [Errno 110] ETIMEDOUT

is there error in library, or my code... ?

@mcauser
Copy link
Owner

mcauser commented Aug 16, 2023

Possibly related to #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.

@dingo27mobile
Copy link
Author

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.

@mcauser
Copy link
Owner

mcauser commented Aug 18, 2023

The OSError suggests the display was not found on the I2C bus.
If you perform an i2c.scan(), can you see a 60 / 0x3C?

@dingo27mobile
Copy link
Author

yes, the "i2c.scan()" prints 60.

@gigagoex
Copy link

gigagoex commented Oct 30, 2023

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!

@mcauser
Copy link
Owner

mcauser commented Feb 26, 2024

Thanks for the feedback.
I've been mainly using this with ESP32's. I'll do some testing with Pis before my next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants