OLED I2c Display With Arduino

625,014

220

110

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

41 People Made This Project!

Recommendations

  • Reclaimed Materials Contest

    Reclaimed Materials Contest
  • Hide It Challenge

    Hide It Challenge
  • Laser Challenge

    Laser Challenge

110 Comments

0
Aljosha
Aljosha

Question 6 months ago on Step 1

Is it possible to use this display to see the frequencies from 100-600 MHz ? If you can help, please do so. If we can make any practical decision, it will help me a lot. It will make me to order more than 50 of this display in the first wave.
Lot of thank for your time and efforts to help.
Very Kind Regards, Nik.

0
LikWid-Official
LikWid-Official

Question 9 months ago

Hey there, I'm getting _this_ error

In file included from C:\Users\Owner\Documents\Arduino\libraries\Adafruit-GFX-Library-master\Adafruit_GrayOLED.cpp:20:0:
C:\Users\Owner\Documents\Arduino\libraries\Adafruit-GFX-Library-master\Adafruit_GrayOLED.h:30:10: fatal error: Adafruit_I2CDevice.h: No such file or directory
#include <Adafruit_I2CDevice.h>
^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino Uno.

Anyone have any idea what this means? I made sure to include and install all listed libraries.

0
PoloR2
PoloR2

Answer 8 months ago

Hello,
Install the library with the library manager (in arduino), and choose the last version.

0
AJ_Schweiz
AJ_Schweiz

10 months ago

Thanks, helped me a lot running the display

0
emallon
emallon

Tip 1 year 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

4 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 4 years ago

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

0
JerryE4
JerryE4

Reply 1 year 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 1 year 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 3 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 4 years ago

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

0
FaisalMal
FaisalMal

Reply 4 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 4 years ago

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

0
offtherails2010
offtherails2010

2 years ago

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

0
AlexO116
AlexO116

3 years ago

I have this problem, what I have to do?

IMG_20181005_132629.jpg
0
sidharthb
sidharthb

Reply 2 years 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 2 years ago

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

20181220_192744(0).jpg