> For the complete documentation index, see [llms.txt](https://cavedu.gitbook.io/linkit-7697/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cavedu.gitbook.io/linkit-7697/linkit-7697-development-guide-for-arduino-ide/tutorial/using-oled-module-sh1106-ssd1306...-etc..md).

# Using OLED module (SH1106 / SSD1306... etc.)

![](https://3972650740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY4gduUSLWOCI23CXUWej%2Fuploads%2F1rAkk2uQYqFW0TXzqm9C%2FIMG_3862.jpeg?alt=media\&token=ac909f79-2e94-4c6c-986f-382563b7f84b)

[Dowload Driver](https://github.com/MediaTek-Labs/linkit-7697-peripheral-drivers-for-arduino/tree/master/U8g2_Arduino-master)

Other than the Grove OLED, you might use other OLEDs which are with different controllers. Based on the work of [olikraus](https://github.com/olikraus), we ported the [original U8g\_Arduino library](https://github.com/olikraus/U8g2_Arduino) to [LinkIt 7697 BSP](https://github.com/MediaTek-Labs/Arduino-Add-On-for-LinkIt-SDK). You can [download](https://github.com/MediaTek-Labs/linkit-7697-peripheral-drivers-for-arduino/tree/master/U8g2_Arduino-master) and use it to drive different types of OLEDs with LinkIt 7967. For details, you can check [the compete list](https://github.com/olikraus/u8g2/wiki/u8g2setupcpp) of supported OLEDs in the official WiKi. For how to install the driver, you can also refer to another tutorial for installing it. Here we give a brief example to show how to use it and a commonly-seen issue.

### Hardware Setup <a href="#usingoledmodule-sh1106-ssd1306...etc.-hardwaresetup" id="usingoledmodule-sh1106-ssd1306...etc.-hardwaresetup"></a>

![](https://3972650740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY4gduUSLWOCI23CXUWej%2Fuploads%2F424lq7A4O4XTXebsq3nJ%2Fssd1306.png?alt=media\&token=5c2beeb8-b898-494a-b2de-abe38ebec3b9)

We use a [4-pin 128x64 I2C OLED module](http://www.icshop.com.tw/product_info.php/products_id/17636) as the example. Connect the **3V3** / **GND** / **P8** / **P9** pins on LinkIt 7697 to **VCC** / **GND** / **SCL** / **SDA** pins on the OLED module, respectively. After installing [the driver](https://github.com/MediaTek-Labs/linkit-7697-peripheral-drivers-for-arduino/tree/master/U8g2_Arduino-master), open the example under **File / Examples / U8g2 / page\_buffer / GraphicsTest** sub-menu in the Arduino IDE. Follow the initialization process in the **Software Setup** section below, compile and upload this sketch to LinkIt 7697, you should be able to see different patterns displaying on the OLED module.

{% embed url="<https://youtu.be/DSezuCMvuKM>" %}

### Software Setup <a href="#usingoledmodule-sh1106-ssd1306...etc.-softwaresetup" id="usingoledmodule-sh1106-ssd1306...etc.-softwaresetup"></a>

After opening the **GraphicsTest** example sketch, you'll see lots of constructors commented out in the beginning of the file. Uncomment one of them according to the part number (and the interface, e.g. HW I2C or SPI) of the driving IC on your OLED module. For example, the driving IC on our testing set is **SH1106** with **HW I2C**, so we uncommented **Line 71** to  instantiate the module correctly:

```
//U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);	// same as the NONAME variant, but maximizes setContrast() range
//U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
//U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);		// same as the NONAME variant, but maximizes setContrast() range
//U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE);   // Adafruit Feather M0 Basic Proto + FeatherWing OLED
```

Then compile and upload the sketch file to LinkIt 7697. You'll see different patterns showing on the OLED module.

{% hint style="danger" %}
Note

There are some 128x64 OLED modules marked with the **SSD1306** driving IC but in fact they are **NOT**. If you used the SSD1306 constructor to drive an OLED module and saw patterns offsetting by some pixels (the left side are cut and the right side shows uninitialized columns) like below, this indicates it's not a SSD1306 OLED module. In our case, it's a SH1106 instead ([Reference](https://github.com/olikraus/u8g2/issues/149)).

![](https://3972650740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY4gduUSLWOCI23CXUWej%2Fuploads%2Fh1F9QRg43AP9AVszBWuL%2FIMG_3861.jpeg?alt=media\&token=c4e1c44b-746e-4352-aa13-45ecdfa29aad)
{% endhint %}
