OLED I2c Display With Arduino

586,910

206

104

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.

Parts:

  • 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.

First Time Author Contest

Participated in the
First Time Author Contest

40 People Made This Project!

Recommendations

  • Battery Powered Contest

    Battery Powered Contest
  • Plywood Challenge

    Plywood Challenge
  • Plastic Contest

    Plastic Contest

104 Discussions

0
emallon
emallon

Tip 17 days ago

We usually don't have enough ram for the Adafruit libraries - but these displays are not that hard to drive directly. And with I2C OLED's getting so cheap lately, there's no reason to squash it all onto just one display either:

https://thecavepearlproject.org/2020/11/15/adding-...

DualOLEDscreens_1_300px.jpg
0
FaisalMal
FaisalMal

3 years ago

Hello,

My OLED is a just white color I want to change to different color.

Is it possible?

Thank you and wish you a nice day.

0
thomas30
thomas30

Reply 3 years ago

Most of these small OLED displays can only use black and white

0
JerryE4
JerryE4

Reply 10 months ago

I burned one of these up years ago, and tore it apart. The one I had was a yellow top over blue bottom. When pulled apart, the color was done using pretty much gel paper to color the white true color of the OLED display..

0
JerryE4
JerryE4

Reply 10 months ago

Years ago I worked in theatrical lighting and stage sound. We used Gel Paper to change the color of spot lights as well as floods for effective presentations. A short time ago, my wife complained that one of the clock kits I built for fun was to bright, so I did a quick search for this on Ebay and found it readily available. I ordered a small square, about 1 foot square, and cut a small piece from a corner, I added that to the face of the clock and it lowered the brightness as well as changing the color to a much deeper green (I ordered green gel paper)

0
Culturedropout
Culturedropout

Reply 2 years ago

If it's white, I'd think you could put a square of colored acetate or some other transparent tinted plastic over the display to get whatever color you want. Assuming you mean you know it's a monochrome display and you're not wanting to change colors under program control.

0
Alex_1998
Alex_1998

Reply 3 years ago

I suppose, it is impossible. The colour is unchangeable, it defined by the used OLED type.

0
FaisalMal
FaisalMal

Reply 3 years ago

Is there different ROLES with the same controller but different color? because as you can see up there it's blue .

0
Alex_1998
Alex_1998

Reply 3 years ago

Yes, you are rigth. The same SSD1306 controller can supplied with blue or white monohrome display panels.

0
offtherails2010
offtherails2010

1 year ago

well done, thanks for the tutorial, this is fantastic ! much appreciated !

0
AlexO116
AlexO116

2 years ago

I have this problem, what I have to do?

IMG_20181005_132629.jpg
0
sidharthb
sidharthb

Reply 1 year ago

You are a life saver .. can you help me with this "every second line is blank... "

WhatsApp Image 2019-08-28 at 13.11.17.jpeg
0
PhilipD67
PhilipD67

Reply 1 year ago

Same here. I have no solution yet. Maybe someone has an idea what it could be?

20181220_192744(0).jpg
0
WijnandJan
WijnandJan

Question 1 year ago on Step 1

What if I want to use other pins for i2c as standard for the board?

0
Jean0x7BE
Jean0x7BE

1 year ago

There are a lot of comments about the usage of an external power supply. This usually won't be needed! There are a number of reasons that can be the case in my situation, and I haven't tried alternatives later.

SO IN MOST CASES, YOU WON'T NEED TO USE AN EXTERNAL POWER SUPPLY (PSU)!

On the positive side, this shows for those whom are new to it how to use two power supplies, with the required common ground and so forth ;)

0
Jean0x7BE
Jean0x7BE

Tip 1 year ago

There are many people that power the display with the internal power supply / power supply from the arduino. This is NO PROBLEM in most cases; in my case it was a problem, possibly caused by a number of variables.

Noting a couple of points that can be the cause:
* Faulty arduino-clone
* Faulty USB-port with regard to its power lines
* Problems powering directly from the FTDI/USB-chip (I belive was CH340 on this one)
* Missing pull-up resistors

Sorry if this is not clear enough in the instructions, but you can power it fine with most arduinos, especially original hardware has spesifications that should power it just fine.

On the other hand, with this setup, you can also quickly learn how to "bind" two power supplies in the same setup (commond ground).

0
StevenV24
StevenV24

4 years ago

You said: "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".

This is somewhat strange ... some of the replyers have no problem with powering from the arduinos 5V?

0
CraftKing7777
CraftKing7777

Reply 4 years ago

Maybe they are plugging into usb 3.0 while he is using USB 2.0 which only supplies half the current of 3.0