Having trouble getting a simple OLED ssd1306 driven device to work. I'm using the sample code from
https://datasheets.raspberrypi.com/pico ... on-sdk.pdf
IDE is Thonny on MacOS
the relevant segment of my code is
print("I2C Address : "+hex(i2c.scan()[0]).upper()) # Display device address
print("I2C Configuration: "+str(i2c)) # Display I2C config
oled = SSD1306_I2C(WIDTH, HEIGHT, i2c) # Init oled display
the output is
I2C Address : 0X27
I2C Configuration: I2C(0, freq=200000, scl=9, sda=8)
Traceback (most recent call last):
File "<stdin>", line 21, in <module>
File "/lib/ssd1306.py", line 110, in __init__
File "/lib/ssd1306.py", line 36, in __init__
File "/lib/ssd1306.py", line 71, in init_display
File "/lib/ssd1306.py", line 115, in write_cmd
OSError: [Errno 5] EIO
Thanks for insights.
OLED display
Re: OLED display
According to the data sheet, the I2C address of a ssd1306 is 0x3c or 0x3d. The driver uses 0x3c as default. If your display uses a different address, you have to specify it in the constructor, e.g.
oled = SSD1306_I2C(WIDTH, HEIGHT, i2c, addr=0x27) # Init oled display
Or do you have other devices connected to the I2C bus as well? What is the result of:
print(i2c.scan())
oled = SSD1306_I2C(WIDTH, HEIGHT, i2c, addr=0x27) # Init oled display
Or do you have other devices connected to the I2C bus as well? What is the result of:
print(i2c.scan())
Re: OLED display
Thanks for the fast reply ...
code now reads:
i2c = I2C(0) # Init I2C using I2C0 defaults, SCL=Pin(GP9), SDA=Pin(GP8), freq=400000
print("I2C Address : "+hex(i2c.scan()[0]).upper()) # Display device address
print("I2C Configuration: "+str(i2c)) # Display I2C config
print(i2c.scan())
output is
I2C Configuration: I2C(0, freq=399361, scl=9, sda=8)
[39]
Unsure how to interpret this ...
code now reads:
i2c = I2C(0) # Init I2C using I2C0 defaults, SCL=Pin(GP9), SDA=Pin(GP8), freq=400000
print("I2C Address : "+hex(i2c.scan()[0]).upper()) # Display device address
print("I2C Configuration: "+str(i2c)) # Display I2C config
print(i2c.scan())
output is
I2C Configuration: I2C(0, freq=399361, scl=9, sda=8)
[39]
Unsure how to interpret this ...
Re: OLED display
The scan returns a single device on the bus, with I2C address decimal 39 or 0x27 hex. As told, 0x27 is not the usual address of a SSD1306 display. Are you sure, that it is a SSD1306 model?
Re: OLED display
The thread seemed to end with potential for the wrong module being used, but I get the same error and as far as I know, I am using a ssd1306. It is 0.91 inch OLED 128x32.
The screen has (apparently) random pixels lit, but nothing resembling what I was trying for.
Any suggestions?
Shell output below:
I2C Address : 0X3C
I2C Configuration: I2C(0, freq=250000, scl=5, sda=4)
Traceback (most recent call last):
File "<stdin>", line 19, in <module>
File "ssd1306.py", line 110, in __init__
File "ssd1306.py", line 36, in __init__
File "ssd1306.py", line 73, in init_display
File "ssd1306.py", line 101, in show
File "ssd1306.py", line 119, in write_data
OSError: [Errno 5] EIO
The screen has (apparently) random pixels lit, but nothing resembling what I was trying for.
Any suggestions?
Shell output below:
I2C Address : 0X3C
I2C Configuration: I2C(0, freq=250000, scl=5, sda=4)
Traceback (most recent call last):
File "<stdin>", line 19, in <module>
File "ssd1306.py", line 110, in __init__
File "ssd1306.py", line 36, in __init__
File "ssd1306.py", line 73, in init_display
File "ssd1306.py", line 101, in show
File "ssd1306.py", line 119, in write_data
OSError: [Errno 5] EIO
Re: OLED display
Error 5 usually indicates a basic communication problem. Do you get the device address when you run i2c.scan()?