Page 1 of 1

Having an issue getting the lib for the SSD1306 working

Posted: Wed Oct 13, 2021 10:19 pm
by Pigeon
have the SSD1306.py in my Lib forler.

Trying to run some simple code:

Code: Select all

from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
import framebuf

WIDTH = 128
HEIGHT = 64

i2c = I2C(0, scl = Pin(17), sda = Pin(16), freq=200000)

oled = SSD1306_I2C(WIDTH, HEIGHT, i2c)

oled.fill(0)

oled.text("I CAN HAZ PANCAKE?", 10, 10)

oled.show
But when I run it I get the following error in Thonny:

Code: Select all

Traceback (most recent call last):
  File "<stdin>", line 10, 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
some googling suggested it could be the I2C address being wrong for my module, but when I do a

Code: Select all

i2c.scan()
I get a reply of [60] so think that means its the default 0X3C?

Re: Having an issue getting the lib for the SSD1306 working

Posted: Sat Oct 16, 2021 7:22 pm
by curt
I had problems with this too. After much searching here is what worked for me:

Code: Select all

# Complete project details at https://RandomNerdTutorials.com

import machine
#from machine import Pin, SoftI2C
import ssd1306
from time import sleep

i2c = machine.SoftI2C(scl=machine.Pin(15), sda=machine.Pin(4))

pin = machine.Pin(16, machine.Pin.OUT)
pin.value(0) #set GPIO16 low to reset OLED
pin.value(1) #while OLED is running, must set GPIO16 in high

oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)

oled.fill(0)
oled.text('Hello, World 1!', 0, 0)
oled.text('Hello, World 2!', 0, 10)
oled.text('Hello, World 3!', 0, 20)
oled.show()
Curt

Re: Having an issue getting the lib for the SSD1306 working

Posted: Fri Oct 29, 2021 5:28 am
by Pigeon
curt wrote:
Sat Oct 16, 2021 7:22 pm
I had problems with this too. After much searching here is what worked for me:
Thank you Curt, forgot to reply that this also worked for me!

Sincerely, Thank you!

Re: Having an issue getting the lib for the SSD1306 working

Posted: Thu Jan 27, 2022 8:34 pm
by Tigran
Thank you Curt, it worked for me too!

Re: Having an issue getting the lib for the SSD1306 working

Posted: Sun Apr 03, 2022 12:32 pm
by mike2545
Using Lib ssd1306.py with 128x32 OLED display
I found that tying 3v3_EN High gets rid of this error.

Code: Select all

Traceback (most recent call last):
  File "<stdin>", line 19, 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
Regards,

Mike2545

Re: Having an issue getting the lib for the SSD1306 working

Posted: Mon Apr 11, 2022 11:51 pm
by Conrad
Hi Mike2545,

I'm also getting EIO error with Tiny 2040 and oled 128x32, tried delays. Can you explain what you did to 'tying 3v3_EN High' ?

Thanks.

Re: Having an issue getting the lib for the SSD1306 working

Posted: Tue Apr 12, 2022 9:22 am
by Shards
No one is saying what boards they are using. I assume the 3.3v Enable pin is on the processor board and controls output on the 3.3v external supply. The majority of boards just have 3.3v available so this is unlikely to be the problem.

I would suspect hardware though. You do have pull up resistors on SDA and SCL don't you?

Re: Having an issue getting the lib for the SSD1306 working

Posted: Tue Apr 12, 2022 12:04 pm
by Conrad
Thanks for reply.

No I don't have pull up resistors on either line - I've only seen this mentioned in one Youtube video and this was when multiple devices were connected on the one I2C bus, all other references (youtube/code) to oled and Tiny/2040 make no mention of these. I will add these next and re-try, 330ohm I think, was mentioned.

I now suspect this is the problem.

Scanning for addresses also returns [] so nothing found.

Re: Having an issue getting the lib for the SSD1306 working

Posted: Tue Apr 12, 2022 12:21 pm
by Roberthh
If the wires are not long 4700 Ohm is a typical value. 330 Ohm is more at the lower edge, resulting in 10mA sink current.

Re: Having an issue getting the lib for the SSD1306 working

Posted: Thu Apr 28, 2022 8:38 pm
by luisfelipeSald
Pigeon wrote:
Wed Oct 13, 2021 10:19 pm
have the SSD1306.py in my Lib forler.

Trying to run some simple code:

Code: Select all

from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
import framebuf

WIDTH = 128
HEIGHT = 64

i2c = I2C(0, scl = Pin(17), sda = Pin(16), freq=200000)

oled = SSD1306_I2C(WIDTH, HEIGHT, i2c)

oled.fill(0)

oled.text("I CAN HAZ PANCAKE?", 10, 10)

oled.show
But when I run it I get the following error in Thonny:

Code: Select all

Traceback (most recent call last):
  File "<stdin>", line 10, 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
some googling suggested it could be the I2C address being wrong for my module, but when I do a

Code: Select all

i2c.scan()
I get a reply of [60] so think that means its the default 0X3C?

Hi, I had the same problem, I solved it by changing the I2C port that I was using, i also change the frequency, from 200000 to 400000, and made some tests with it. In both cases the screen worked properly.
Hope you find this useful :D

Code: Select all

from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
import framebuf


width = 128
height = 64

i2c = I2C(1, scl=Pin(15), sda=Pin(14), freq=400000)

oled = SSD1306_I2C(width, height, i2c)

oled.fill(0)

oled.text("Hola perro", 5, 8)
oled.text("2022", 5, 18)
oled.show()