OLED I2c Display With Arduino





Introduction: OLED I2c Display With Arduino

About: Computer geek who stumbled upon arduino and electronics in general a while ago.

In this instructable I will show you how to connect and test a 0.96" i2c OLED display module to an arduino.


  • Breadboard and hookup wires
  • Arduino (using a nano v3 5v 16mhz clone in this case)
  • External power supply (regulated 5v)
  • The OLED i2c display

I bought my display around 6 months ago, and I can’t seem to find the exact display on ebay now, but searching for “0.96 ssd1306 i2c OLED” shows a whole lot of similar displays. Other sites, like adafruit, got the same displays if you prefer to shop there.

Step 1: Connecting Your Display

The display is connected by utilizing the i2c pins on your arduino.

Which pins to use for this differs on some arduino models, but on the UNO and NANO you use pin A4 (SDA) and A5 (SCL). If you’re using another arduino, google the pinout and look for SDA and SCL pins. (For example, google “arduino mega pinout”, and check the images).

I first attempted to power my display from my arduinos 5v. This worked, but only halfway – the display fired up, and started cycling the demos in the sketch we will see later on, and then froze after a few seconds.

I then powered my display from my external 5v supply (with common ground to the arduino), which did the trick – the display is now working properly.

The connections from the display:

  • VCC to external 5v
  • GND to external GND
  • SCL to arduino pin A5 (or the SCL pin for your arduino)
  • SDA to arduino pin A4 (or the SDA pin for your arduino)
  • arduino GND pin to external psu GND

Arduino is connected to the computer via an USB cable. The USB powers the arduino.

Step 2: I2c Scanner

To start out, we need to find out the i2c address of the display. To
accomplish this, I use a quick i2c scanner uploaded to the arduino. The scanner code can be found on http://playground.arduino.cc/Main/I2cScanner.
Copy and paste the code into your arduino IDE, build and upload, and fire up your serial monitor. If your display are connected, powered and working, you will get an address back from the scanner (in serial monitor). My display shows up at address 0x3C.

Step 3: Libraries

In this instructable I am using the arduino IDE (http://arduino.cc) and libraries from adafruit downloaded via github.
Link to the libraries:

I will assume you know how to download and install libraries in your arduino IDE. If not, there are tons of nice tutorials/instructions out there on how to get started with the arduino IDE and libraries.

Both libraries below needs to be installed before you are able to continue with this instructable.

https://github.com/adafruit/Adafruit_SSD1306 (SSD1306 library)

https://github.com/adafruit/Adafruit-GFX-Library (GFX library)

Step 4: Test Sketch

Now that we know our displays i2c address, we can open the example sketch in our adafruit ssd1306 library.
In your arduino IDE, check your examples menu and locate the 128×64 i2c sketch found under Adafruit SSD1306 (as shown in the picture).
Change the address of the display to whatever the scanner told you, in my case 3x0C.

Compile and upload to your arduino, give it a second, and the display should fire up and show some different display modes.

The demo sketch ends with stars that continues to fall forever. You can copy-paste from the demo sketch to use the display modes that fits your needs.

27 People Made This Project!


  • Planter Challenge

    Planter Challenge
  • Clocks Contest

    Clocks Contest
  • Casting Contest

    Casting Contest

We have a be nice policy.
Please be positive and constructive.


2 Questions

I am new to Arduino so i have a basic question. I think i have install the libs, but the examples don't show up as in the Step 4 image. ant suggestions?

Download the lib from URL mentioned above in a folder say "Download"

Load Arduino, Click Sketch -> Include Library-> Add .Zip and load both the libs

(zip) file downloaded.


Thanks. Had mine up and running on a nano in no time. Powers fine off the usb as well :-)


I get an error in the IDE when compiling, as follows:-

"exit status 1

Error compiling for board Arduino/Genuino Uno"

Any ideas, please?

1 reply

Resolved the problem. The required GFX library wasn't installed. Why an error saying 'cannot find Adafruit_GFX.h library, please install' doesn't show amazes me; that would be a lot more .

Hello there

It's an awesome tutorial.

I want to know in the basic code of testing the 128x32 i2c display they are using reset pin. But there is no reset pin on my OLED display.

Second, I got the flickering display even after giving the external 5V.

What should I do??


3 replies

Regarding the flickering display, double check your VCC and Gnd connections, first. Surprisingly, if Gnd is not connected at all, the display will still sort of work, but flicker / be unstable. When I ran into that, once, I spent a long time looking for the cause at all the wrong places...

Tie both GNDs together on the nano.

The lack of the reset pin seams to be normal.

But this instruction is wrong. You shouldn't let the example code using pin4 as a non-connected reset pin. Instead you should modify the example not using any parameters while constructing the display. (This will lead to a default value -1 to be set as reset pin, and it is handled by the Adafruite driver.)

Also worth to mention that there are SPI-ready versions of this display board, that are also supported by the Adafruite driver. (Buy Adafruite products to support them developing drivers!)

ssd1306_128x64_i2c:54: error: #error ("Height incorrect, please fix Adafruit_SSD1306.h!");

#error ("Height incorrect, please fix Adafruit_SSD1306.h!");


exit status 1

#error ("Height incorrect, please fix Adafruit_SSD1306.h!");

I got this error and can't solve this. Plzz help

1 reply

Thank you too for this tutorial. Unfortunatly, I had the same error than abhishekcshah15. To fix it, I erase the line, (it' only an error message, not very important for testing) ...Less than 5 minutes to test again, and it's work perfectly ! Very good, thank you again!

The Arduino implements internal pullup resistors

Not quite right, some of these displays have pullups included on the display's pbc, had a couple from different places that did that but maybe not all of them? This might be the cause of some people's garbled displays (either that or some i2c clock issue?)

Could also suggest looking at the u8g2 library which supports the ssd1306 driver used commonly in these things.


Thank you for this helpful tutorial. Although I'm new at arduino, I could manage to use my oled by means of your tutorial. Thank you. Hope everybody have a nice year...!

My board for some reason won't compile the 128x64, telling me the height is incorrect, but will compile the 128x32 code, even though, on the box is says it's 128x64. I think I've been ripped off.

4 replies

You have not been ripped off (in all likelihood):

You will have to adjust the *library* in order to tell it you have a 64 lines display. More specifically, locate your arduino "libraries" folder, and edit "Adafruit_SSD1306/Adafruit_SSD1306.h". Search for "#define SSD1306_128_32", disable that line, and enable "#define SSD1306_128_64", instead.

(Yes, that's stunningly bad design, but again, it's a problem in the library, not the display.)

Wouldn't it display incorrectly though? I'll give it a go but.

Happened to me also...but on Aliexpress those displays are so cheap that I don't even minded. I thought mine wasn't working on the beginning, the address told my the manufacturer is wrong.

All well and good but mines from a local retailer and was something like $15 or so. Not really thrilled but it works I guess. I might check the .h file though.

My Arduino Nano (cheap Chinese clone) was able to power the display via its 5V regulated output though it was plugged into a powered USB hub and not into the computer directly.

Possibly, only, the USB port of your computer was not strong enough to supply enough power.

If you're seeing every second line as blank, like I was, you need to edit the library file to uncomment:

`#define SSD1306_128_64`

and comment out

`// #defineSSD1306_128_32`


1 reply

Thank you for the nice tip and adding value to the tutorial!