0

Error:

>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
  File "<stdin>", line 5, 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

My script:

from machine import Pin, I2C
from ssd1306 import SSD1306_I2C

i2c = I2C(0, sda=Pin(16), scl=Pin(17), freq=40000)
oled = SSD1306_I2C(128, 64, i2c)

oled.fill(0)
oled.text("Hello", 0, 0)
oled.show()
import machine
import ssd1306
import time

# Define the pins for I2C communication
i2c = machine.I2C(0, sda=machine.Pin(16), scl=machine.Pin(17), freq=400000)

# Define the display object
oled = ssd1306.SSD1306_I2C(128, 64, i2c)

# Clear the display
oled.fill(0)
oled.show()

# Display something
oled.text("Hello, Pico!", 0, 0)
oled.show()

What causes the issue?

user4157124
  • 2,809
  • 13
  • 27
  • 42
Pinnache
  • 1
  • 1
  • https://forums.raspberrypi.com/viewtopic.php?t=339160 exactly the same issue – Lixas Aug 25 '23 at 10:01
  • Maybe try scanning the I2C bus to make sure your display is wired correctly and detected. ``` print('Scanning i2c bus...'); devices = i2c.scan(); if (len(devices) == 0): print("No i2c device !"); else: print('Devices found:', len(devices)); for address in devices: print("Address: ", hex(address)); ``` Sorry, Markdown formatting doesn't work in the comments. I put semicolons at line ends to help. – Dave H. Aug 28 '23 at 00:18

0 Answers0