SH1106/I2C OLED driver on pyboard

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
Post Reply
User avatar
douglas.young
Posts: 3
Joined: Thu Nov 12, 2020 3:16 am

SH1106/I2C OLED driver on pyboard

Post by douglas.young » Wed Mar 09, 2022 9:19 pm

I am trying to use an SH1106 OLED connected by I2C to a pyboard. The OLED is a 1.3" 128x64 module I purchased from amazon
(https://smile.amazon.com/gp/product/B07 ... UTF8&psc=1). I am using the driver I found at https://github.com/scy/SH1106. I am running a slightly modified version of the example code posted with the driver:

from machine import Pin, I2C
import sh1106
#
i2c = I2C(scl=Pin('X9'), sda=Pin('X10'), freq=400000)
display = sh1106.SH1106_I2C(128, 64, i2c, None, 0x3c)
display.sleep(False)
display.fill(0)
display.text('Testing 1', 0, 0, 1)
display.show()

When I run this, get the following error message:

Warning: I2C(-1, ...) is deprecated, use SoftI2C(...) instead
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
File "sh1106.py", line 173, in __init__
File "sh1106.py", line 111, in __init__
File "sh1106.py", line 116, in init_display
File "sh1106.py", line 123, in poweron
File "sh1106.py", line 178, in write_cmd
OSError: [Errno 19] ENODEV

I get the same error if I used SoftI2C instead of the hardware I2C. I think the problem may be in the recent I2C implementation on the pyboard; I get a similar error when trying to use a ssd1306 on a different OLED. Any suggestions are welcome.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: SH1106/I2C OLED driver on pyboard

Post by Roberthh » Thu Mar 10, 2022 7:08 am

The reason for a ENODEV error is usually a wiring or configuration problem. It's not the problem of the SH1106 driver or the way you instantiate the I2C object. PyBoard has pull-up resistors at the board. So it's not a problem of missing pull-up. Just to ask the obvious:
Did you connect all of GND, Vcc, SCL and SDA between PyBoard and the display?
After creating the I2C object, what is the result of i2c.scan(). It should return a list containing the I2C address as decimal number. If the list is empty, then it confirms a connection problem.

User avatar
douglas.young
Posts: 3
Joined: Thu Nov 12, 2020 3:16 am

Re: SH1106/I2C OLED driver on pyboard

Post by douglas.young » Sat Mar 12, 2022 5:02 am

Thank you for getting back to me. You were correct. The problem was with the power pins I had soldered to the pyboard. Once I plugged the OLED into power pins that were working the i2c scan found OLED and it worked fine. Your help and patient support are very much appreciated!

DTY

Post Reply