Inland IIC SPI 1.3" 128x64 OLED V2.0 Graphic Display Module and MicroPython SH1106

The title of this is long to hopefully help people find this when they are thinking of buying this cheap Inland OLED.  I was looking to put a display in the center of my Ikea Dekad clock hack and this OLED was priced right.

I've used the Nokia LCD displays in the past but wanted to try something a little brighter with higher contrast.  Microcenter sells an Inland branded OLED module for $7.99 in 2023 dollars.  My biggest gripe with the Inland products is that they have lousy documentation.  This module appears to be made by Keystudio which apparently continues in the Seeed Studio tradition of bare minimum examples and docs.  

The device can support either SPI or I2C.  It comes preconfigured for SPI and I can't find instructions anywhere on how to change it.  This means you have to use 4 MCU pins instead of just two.

There are apparently two main controllers for this type of OLED. This board uses the SH1106.  There is a great MicroPython driver for this chip.  It isn't part of the standard distribution so see the links below.

I had some trouble getting a clear picture of the text. 
I think it is a refresh rate conflict with the camera.

Inland IIC SPI ... 

The Inland IIC SPI 128x64 OLED is pretty cheap at $8. It comes configured for SPI.  The device has an I2C jumper on the back but I can't find instructions as to whether the jumper is the only change required.

This display uses the SH1106 display chip and not the SSD1306.  This means you need the SSH1106 driver

The product page images show that this is made by Keystudio.  The current product has a different silkscreen as you can see on the right.

References - SH1106 and RPI Pico

Using SP1 and pins associated with it.

SPI uses 4 pins.  The Pico is pretty flexible because it lets you choose which physical pins are bound to the hardware SPI.  Each Pico hardware SPI has a set of specific pins to choose from for each function.  You choose one pin out of that set for each function. 

SPI 1 has two pins to choose from for each of the 4 functions. I chose the 4 pins in the red box in the bottom corner.
Click to enlarge

PICO SPI 

I chose Pico SPI 1 and pins GP12 GP13 GP14 and GP15 mostly because the pins were co-located in one corner of the board making assembly easier.  Well not really. I still need to pull power from somewhere.

Board PinPico PinNotes
GNDGNDStay grounded
VCC    3.3v    Some sites say 5V will work
CLKGP14SPI1 SCK (SCL)
MOSIGP15SPI1 TX (SDA)
RES3.3vCould be bound to any pin - supported by the driver
DCGP12SPI1 RX - data/command  
CSGP13SPI1 CSn
.........

Sample Code

This code was extracted from https://github.com/freemansoft/ESP8266-MicroPython  It will probably be relocated at some point.  We're using the Pico's SPI 1 and the SH1106_SPI construct from https://github.com/robert-hh/SH1106 which has been added as a git module to my repo.


from machine import Pin
import time

def demo_sh1106():
    # copy sh1106 to /pyboard. Find it at
    # https://github.com/robert-hh/SH1106
# Example display commands
    # https://docs.micropython.org/en/latest/esp8266/tutorial/ssd1306.html
    from machine import SPI
    import sh1106

    spi1_sck_clk = Pin(14)
    spi1_tx_mosi = Pin(15)
    spi1_rx_miso_dc = Pin(12)
    spi1_csn_cs = Pin(13)

    oled_spi = SPI(1, sck=spi1_sck_clk, mosi=spi1_tx_mosi, miso=spi1_rx_miso_dc)

    display_sh1106 = sh1106.SH1106_SPI(
        128, 64, oled_spi, dc=spi1_rx_miso_dc, cs=spi1_csn_cs
    )
    display_sh1106.init_display()  # clears the display
    display_sh1106.invert(1)
    time.sleep(1)
    display_sh1106.invert(0)
    time.sleep(1)
    display_sh1106.text("Hello World!", 0, 0, 1)
    # this text will be truncated -- appropriate I think for a goodbye message
    display_sh1106.text("So long. Thanks", 0, 10, 1)
    display_sh1106.text("Thanks for the ", 0, 20, 1)
    display_sh1106.text("fish", 0, 30, 1)
    display_sh1106.show()
    time.sleep(2)
    display_sh1106.fill(0)  # clears the display
    display_sh1106.show()


Supplemental notes

I found these references useful while learning how to use the board.

Other References

From the inland product page on the Microcenter site

There was one review on the Microcenter site that showed how to use this with the Arduino library.  See the product page.  I didn't want to violate any ToS for that review.

Arduino lib  options provided by Keystudio

This section is purely for reference.  I found it while looking for Python support. Arduino users will use the U8GLIB. It will be one of these.  
// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9);

// SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED)
U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7);

// I2C / TWI 
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE);	

// Dev 0, Fast I2C / TWI
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_FAST);

// Display which does not send ACK
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NO_ACK);	

Revision History

Created 2023 01

Comments

Popular posts from this blog

Understanding your WSL2 RAM and swap - Changing the default 50%-25%

Installing the RNDIS driver on Windows 11 to use USB Raspberry Pi as network attached

DNS for Azure Point to Site (P2S) VPN - getting the internal IPs