Pi Pico with AZ-Delivery 1.3" OLED

Hi… I recently purchased an AZ-Delivery 1.3" OLED display unit for use with one of my Pi Pico MCU’s. When I connected the display unit to the Pi Pico and ran the following code from Thonny the display just dissolved into a mass of randomly lit and unlit pixels.

from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
w = 128
h = 64
i2c = I2C(0, scl = Pin(17), sda = Pin(16), freq=200000)
addr = i2c.scan()[0]
oled = SSD1306_I2C(w, h, i2c, addr)

add some text

oled.text("Raspberry Pi ", 5, 5)
oled.text(“Pico ssd1306”, 5, 30)

The problem, as I see it (a person who is a very, very beginner at code writing) the I2C connections available on the Pi Pico are 0&1…but there seems to be some 5 or 6 sets of SCL/SDA pairs of 0&1’s. So how am I supposed to know which SCL/SDA pair to use to communicate between the two units?? Does anyone know some GOOD code to allow the Pi Pico to “talk” to the AZ-Delivery 1.3" OLED display unit … I do not know if the coding for this particular OLED might be different from other display units such as the Waveshare display.

From the AZ delivery product page:

Thanks to standard controller (SSH 1106) already libraries for Raspberry Pi and Co. available

From your code:

from ssd1306 import SSD1306_I2C

Screens have a controller chip which handles receiving data from the I2C bus, and then showing it on the screen. You need to have code which is appropriate for your contrller chip. I’d guess that SSD1306 code is similar enough to code for the SSH1106 that things happen, but not in any sort of sensible way. You may need to find a better software module, try looking for other SSH1106 screens and see if the manufacturer has a software module for them.

As for how you know which pins to use:

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

As long as scl and sda map to a pair of I2C pins on the Pico Pinout map then it should be fine. If you’re using a pair marked i2c1 then you’ll need to change the 0 to 1 at the start of that function too.

You are definitely using the wrong display driver. The SH1106 is not the same as the SSD1306. You are trying to drive a 128x64 display with a driver that handles 132x64. Not much difference, but you can expect that this causes the trouble.

Ask google for the correct SH1106 MicroPython driver, there are many available.