Hello,
I simply tried to get my plain oled SSD1309 work these days. After lots of struggles I encountered the error " [Errno 16] Device or resource busy", and after googled a while I found a few people complain the similar things, such as,
OSError running sample script for MCP3008 on Libre Computer aml-s905x-cc "Le Potato" · Issue #681 · adafruit/Adafruit_Blinka · GitHub or,
[Errno 16] Opening input line handle: Device or resource busy · Issue #188 · kantlivelong/OctoPrint-PSUControl · GitHub.
Below is one of the code snippets I tried and the error message. Basically I’m trying different python packages and all of them pop out the same error message.
import adafruit_ssd1306
import board
import busio
import digitalio
import time
from PIL import Image, ImageDraw, ImageFont
WIDTH = 128
HEIGHT = 64
BORDER = 5
#spi = busio.SPI(board.SCK, MOSI=board.MOSI)
spi = busio.SPI(board.P23,MOSI=board.P19)
#reset_pin = digitalio.DigitalInOut(board.D17)
reset_pin = digitalio.DigitalInOut(board.P18)
#dc_pin = digitalio.DigitalInOut(board.D22)
dc_pin = digitalio.DigitalInOut(board.P22)
#cs_pin = digitalio.DigitalInOut(board.CE0)
cs_pin = digitalio.DigitalInOut(board.P24)
oled = adafruit_ssd1306.SSD1306_SPI(WIDTH, HEIGHT, spi, dc_pin, reset_pin, cs_pin)
# clean up screen
oled.fill(0)
oled.show()
# blank page
image = Image.new("1", (oled.width, oled.height))
draw = ImageDraw.Draw(image)
draw.rectangle((0, 0, oled.width, oled.height), outline=255, fill=255)
draw.rectangle((BORDER, BORDER, oled.width - BORDER - 1, oled.height - BORDER - 1), fill=0, outline=0)
font = ImageFont.load_default()
text = "Hello World!"
(font_width, font_height) = font.getsize(text)
draw.text(
(oled.width // 2 - font_width // 2, oled.height // 2 - font_height // 2),
text,
font=font,
fill=255,
)
try:
while True:
oled.image(image)
oled.show()
time.sleep(3)
except KeyboardInterrupt:
oled.fill(0)
oled.show()
Traceback (most recent call last):
File "/home/michshell/Repositories/SSD1309/busio_ssd1309.py", line 21, in <module>
cs_pin = digitalio.DigitalInOut(board.P24)
File "/home/michshell/.local/lib/python3.9/site-packages/digitalio.py", line 165, in __init__
self.direction = Direction.INPUT
File "/home/michshell/.local/lib/python3.9/site-packages/digitalio.py", line 195, in direction
self._pin.init(mode=Pin.IN)
File "/home/michshell/.local/lib/python3.9/site-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod_pin.py", line 115, in init
self._line.request(config)
File "/home/michshell/.local/lib/python3.9/site-packages/gpiod/libgpiodcxx/__init__.py", line 553, in request
rv = libgpiod.gpiod_line_request(_m_line, conf, default_val)
File "/home/michshell/.local/lib/python3.9/site-packages/gpiod/libgpiod/__init__.py", line 479, in gpiod_line_request
return gpiod_line_request_bulk(bulk, config, [default_val])
File "/home/michshell/.local/lib/python3.9/site-packages/gpiod/libgpiod/__init__.py", line 522, in gpiod_line_request_bulk
return _line_request_values(bulk, config, default_vals)
File "/home/michshell/.local/lib/python3.9/site-packages/gpiod/libgpiod/__init__.py", line 387, in _line_request_values
status = ioctl(fd, GPIO_GET_LINEHANDLE_IOCTL, req)
OSError: [Errno 16] Device or resource busy
Anyone knows how to lighten up the spi oled in any way?