Interacting with an OLED Display via an I2C Bus system | Diy Project

Hello! I’m back with another beginners’ tutorial. This time, we will interact with an OLED 0.96” Display using the I2C Bus. Now let’s get started.

For this tutorial, the project list is short. You only will need an Arduino Nano and an OLED Display. For the second part of this tutorial, you will also need an Atmega 328p microcontroller, which is used in the Arduino UNO and Nano, for example. You will need some other components for the second part, but let’s begin with the first part: connecting it to an Arduino Nano.


Interacting with an OLED Display via an I2C Bus by using Arduino Nano 


First of all – what is I2C? It is a protocol mainly used for sensors and displays, which allows them to communicate with a Microcontroller (for example) via a serial connection. This Bus system consists of 2 wires: SCL (Serial Clock) and SDA (Serial Data). Feel free to read more about it on the Sparkfun forum, if you are interested.

This is the display I will use for this tutorial:

Now we will have to wire it up to the Arduino Nano on a breadboard like shown below in the schematics:

Arduino Nano Oled Display
A4 SDA
A5 SCL
5V VCC
GND GND

Now, in order to display something on it, we need to program the Arduino Nano. We need to run 2 programs. One to detect the I2C address of the Display, and one program which displays what we want. You can get the code for the scanner from below the tutorial.

After you upload it, open the serial monitor and copy the address. We will need it to communicate with the display.

Next step is to download the library for this display, which you can get here:

Just put the content of the folders into Arduino –> libraries.

Now let’s get to the program that lets us interact with the display. For this, in the Arduino IDE go over to Examples and open the code, and then you need to put in the address you just copied beforehand, like shown below:

And put the address like this:

Now upload the code and enjoy a presentation of images and bitmaps. Now feel free to play with the numerous functions in the example code and let your imagination flow.


Interacting with an OLED Display via an I2C Bus by using (ATMEGA 328p breakout)


Now, for the second part of this tutorial, we will do the same thing as before, but just with a simple Atmega 328p Microcontroller, freed from the Arduino board.

Before going on with this tutorial, you need to make sure that the Atmega has the bootloader already on it. If you got a brand new Atmega, there is no bootloader on it, but if you unplugged it from an Arduino UNO, there is already a bootloader on it. If you need to burn the bootloader, follow the link: How to Program Arduino Bootloader uploaded Atmega 328 IC

You will need these components:

  • FTDI Breakout Board
  • Atmega 328p microcontroller
  • Breadboard
  • 1x 10k resistor
  • 2x 20pF capacitors
  • 1x 100µF capacitor
  • 2x 100nF capacitors
  • 1x push button
  • Jumper wires
  • Optional:
  • 1x 3mm green LED (Rx pin)
  • 1x 3mm white LED (Tx pin)
  • 1x 5mm blue LED (Built-in LED like on the Arduino)

Optionally you can add 2 LED’s for the Rx and Tx pins, which will light up when you upload code or use the serial interface, just like an Arduino would do. You can also add the built-in LED, like on the Arduino by using the digital Pin 13, as shown below:

Oled Display Atmega 328p
VCC VCC
GND GND
SCL A5 (Pin 28)
SDA A4 (Pin 27
FTDI Breakout Board Atmega 328p
VCC VCC
GND GND
RxD Tx (Pin 3)
TxD Rx (Pin 2 )
DTR RESET ( Pin 1 over a 100nf Capacitor)

Connect the FTDI Breakout to the PC and upload the code.

Now you have the same setup as beforehand, and you can build your awesome project along this setup, so you can display useful information!

Related posts

Arduino Opta PLC Pros & Cons

Breakthrough of Ardino-Pro Opta: Micro-PLC with industrial IoT proficiency

Top Arduino sensors – the ultimate list 2021