Jan 6, 2018

OLED I2c Display
with Arduino Nano

ssd1306 oled display

I will show you how to connect and program a 0.96" i2c OLED display module to an Arduino Nano, in this tutorial a 0.96 inch monochrome OLED display is connected to an Arduino Nano. Libraries are then installed and some example programs run which show how to use the display in an Arduino sketch. The display connects to Arduino using only four wires – two for power and two for data, making the wiring very simple. The data connection is I2C (I²C, IIC or Inter-Integrated Circuit). This interface is sometimes called TWI (Two Wire Interface). At the very lowest level, the Arduino Wire library is used to communicate with the display. Libraries are available that make it easy to start using the display right away to display text and graphics. These libraries are installed in this tutorial.

arduino nano
The display used in this tutorial has a very small (2.7 x 2.8cm) OLED screen, with 128 x 64 screen resolution. The OLED Driver IC is a SSD1306, a single-chip CMOS OLED/PLED driver with controller for organic / polymer light emitting diode dot-matrix graphic display system. The module has only 4 pins, two of them are the supply pins, while the others are SCL and SDA, the I2C protocol pins, which will be used to control the display.

Getting Started

Arduino Nano pin out

Hook up your Arduino OLED Wiring

  1. OLED GND – Arduino GND
  2. OLED VCC – Arduino 5V
  3. OLED SCL – Arduino A5
  4. OLED SDA – Arduino A4
  5. For the power supply of the Display, you can either power it at 5V or 3.3V.

Why wire the SDA and SCL to (Analog pin) A4 & A5? Since the Adafruit library uses the Wire Library, the pins for the SDA & SCL pins are defined to be at A4 & A5 for I2C communication. For more information about the Wire library

  • Extract the Adafruit_SSD1306-master.zip. Rename the extracted folder to Adafruit_SSD1306. Place the Adafruit_SSD1306 folder inside your /libraries/ folder. (Which is most likely found in “My Documents/Arduino”). If there is no such folder, create one.
  • Repeat step 2 for the Adafruit GFX library.
  • Start the Arduino IDE
  • We need to find out the i2c address of the display. To accomplish this, I use a quick i2c scanner uploaded to the arduino. Scanner code can be found playground arduino . Place the I2c Scanner in “My Documents/Arduino/i2c_scanner”. Copy and paste the code into your arduino IDE, build and upload, and fire up your serial monitor.
  • Open up I2c Scanner and upload

i2c scanner

  • Open Serial Monotor
  • If your display is connected, powered and working, you will get an address back from the scanner (in serial monitor). My display shows up at address 0x3C.

Serial Monotor

  • Open Examples -> Adafruit_SSD1306 -> ssd1306_128x64_i2c


  • I would be using the Adafruit sample code with a minor tweak, since the address of my OLED Display is different from the one used in their sample code. The only change you have to do is to change the I2C address of the display from 0x3D to 0x3C before uploading the code onto the Arduino board.
  • displays i2c address

    Adafruits indus
    oled clock