Help needed getting MicroPython Driver for SSH1106 working

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
User avatar
Pip
Posts: 11
Joined: Mon Jul 12, 2021 6:37 pm
Contact:

Help needed getting MicroPython Driver for SSH1106 working

Post by Pip » Mon Jul 12, 2021 7:11 pm

Hi
I am new to MicroPython so this is a bit of a noob question:
  • Got a Raspberry Pi-Pico connected to Windows 10 64 bit
  • Coding in MicroPython 3.7.9 (32-bit) via Thonny 3.3.3
  • Purchased an OLED SSH1106 but have not been able to locate any drivers via PyPi but I have managed to located a candidate by robert-hh on GitHub,
    https://github.com/robert-hh/SH1106
Where I see an sh1106.py file, I can't work out how to install/access it and import it into my code. I even tried just popping the above mentioned file in the same directory as my code, but all I get is the classic ImportError: no module named 'sh1106' error.

I Google on installing packages without using pip (pun intended) :) but that lead me down a rabbit hole so deep I needed to come up for air, hence posting my query here.

Any pointers of how to get Robert's driver working would be most welcome.

Cheers
Pip

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

Re: Help needed getting MicroPython Driver for SSH1106 working

Post by Roberthh » Mon Jul 12, 2021 7:44 pm

I cannot tell you much about Thonny ad the way to transfer files to the board. But the Author of Thonny will surely answer that part. He is a regular visitor of this board. As the co-author of the sh1106 driver I can answer that part. Both the sh1106.py and the readme.md file have short code examples about using the driver. You have to tell first whether the display you have uses the SPI or I2C interface. They can be configured for both modes. The examples in the files are for ESP8266. But the only difference to the RP2 is the way, the SPI of I2C object is instantiated and the number of the GPIO pins used.

Note: Sometimes SSD1306 displays are sold as SH1106 models. So if everything else fails, try the SSD1306 driver.

User avatar
Pip
Posts: 11
Joined: Mon Jul 12, 2021 6:37 pm
Contact:

Re: Help needed getting MicroPython Driver for SSH1106 working

Post by Pip » Mon Jul 12, 2021 8:04 pm

Hi Robert,
Thank you for your prompt reply. Yes i have seen your sample code, which is where I am staring from. However until I can import the module I can't go any further.

While looking around I have seen tutorials of how to make modules in python and import them, but this is not working in Thonny, or at least not for me.

I will wait and see if a Thonny expert can help.

Cheers

Pip

User avatar
Pip
Posts: 11
Joined: Mon Jul 12, 2021 6:37 pm
Contact:

Re: Help needed getting MicroPython Driver for SSH1106 working [SOLVED]

Post by Pip » Mon Jul 12, 2021 8:52 pm

SOLVED:

I pared things back to a most basic bit of test code, then made a simple 3 line function test stub and tied to import it into a simple test program. I tried various options and permutations and discovered that it would work if and only IF the function/module that needed to be imported had been saved into the Pico’s internal memory. Although the program ran fine from the Windows computer’s directory, the module itself needed to be on the Pico internal memory. I am guessing this is a path issue?

So now it’s just a case of making sure the the sh1106.py file is on the Pico itself, not on the computer.

My display is now happily saying “Testing 1”

In answer to your question Robert, it is the I2C version of the SSH1106. I got an ‘TypeError: 'id' argument required’ at first, but then added an id number of 0 to the i2c setup line in your sample code and bingo! we are up and running.

Your comment:
Thonny ad the way to transfer files to the board"
got me thinking. So thank you for your help.

Cheers

Pip

Post Reply