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.
Hook up your Arduino OLED Wiring
- OLED GND – Arduino GND
- OLED VCC – Arduino 5V
- OLED SCL – Arduino A5
- OLED SDA – Arduino A4
- 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
- Download the following libraries below. Both libraries are required to interface the Arduino to the OLED Display
- Adafruit_SSD1306 OLED I2c Display With Arduino
- Adafruit_SSD1306 Adafruit-GFX-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
- 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.
- Open Examples -> Adafruit_SSD1306 -> ssd1306_128x64_i2c