Skip to content

Instantly share code, notes, and snippets.

@jouellnyc
Last active May 21, 2025 01:47
Show Gist options
  • Save jouellnyc/f016fbe638d2beff33d8b4ad2fb9b36d to your computer and use it in GitHub Desktop.
Save jouellnyc/f016fbe638d2beff33d8b4ad2fb9b36d to your computer and use it in GitHub Desktop.
Micropython ssd1306 1.3 inch oled
"""
The 1.3" I2C 128x64 OLED will use sh1106 and NOT ssd1306 drivers:
i.e https://www.amazon.com/HiLetgo-SSH1106-SSD1306-Display-Arduino/dp/B01MRR4LVE?th=1
The .96" I2C 128x64 OLED will use ssd1306 drivers:
i.e https://www.amazon.com/DIYmall-Serial-128x64-Display-Arduino/dp/B00O2KDQBE?th=1
"""
from machine import Pin, I2C
oled_width = 128
oled_height = 64
I2C_LANE = 1
I2C_SDA_PIN = 14 # Example SDA pin (GPIO19 on Pico)
I2C_SCL_PIN = 15 # Example SCL pin (GPIO20 on Pico)
which='1.3'
i2c_oled = I2C(I2C_LANE, sda=Pin(I2C_SDA_PIN), scl=Pin(I2C_SCL_PIN), freq=200000)
if which == '1.3':
import sh1106
oled = sh1106.SH1106_I2C(oled_width, oled_height, i2c_oled, None, 0x3c)
elif which == '.96':
import ssd1306
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c_oled, addr=0x3C)
oled.text("hello", 0, 0)
oled.show()
@jouellnyc
Copy link
Author

jouellnyc commented May 21, 2025

Front:

image

Back:
image

@jouellnyc
Copy link
Author

jouellnyc commented May 21, 2025

How will you know? How will Google bring you here:

Initial Problem:

  • Display shows a "snowy screen"
  • I2C communication could be failing with ETIMEDOUT errors likely due to lots of changes/troubleshooting
  • Despite being often sold as "SSD1306 / SH1106", the 1.3-inch OLED actually uses the SH1106 controller.

Notes:

  • Always ensure the pin configuration is correct with respect to SDA and SCL/SCK!
  • Set appropriate display dimensions (128x64 pixels)
  • Used the correct I2C address if needed (commonly 0x3C or 0x3D)
  • Adjust the I2C frequency for reliable communication if needed

See:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment