How to connect an OLED SSD1306 to Arduino

0.96″ display on A4 and A5, address 0x3C.

Wiring diagram

Open in the builder

Connections

StepFromToColor
1Arduino Nano GNDOLED SSD1306 GNDblack
2Arduino Nano 5VOLED SSD1306 VCCred
3Arduino Nano A5OLED SSD1306 SCLI2C, green
4Arduino Nano A4OLED SSD1306 SDAI2C, green

Power and wiring check

  • The schematic check, the same as in the builder, found no errors: pin voltages match, ground is common, buses are fully connected.
  • OLED SSD1306 draws up to 25 mA (about 10 typically) from the 5V pin of Arduino Nano, the pin supplies about 400 mA: USB gives 500 mA, the board takes part of it.

Current of the whole circuit and how long it runs on a battery: power budget. Where to plug what: breadboard layout.

Example code

Arduino IDE, Adafruit SSD1306 2.5, Adafruit GFX 1.11.

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 oled(128, 64, &Wire, -1);

void setup() {
  // 0x3D if the address resistor on the back is moved
  if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) for (;;);
  oled.clearDisplay();
  oled.setTextSize(2);
  oled.setTextColor(SSD1306_WHITE);
  oled.setCursor(0, 0);
  oled.println("olerast");
  oled.display();
}

void loop() {}

Part pinouts

Next steps for this circuit

How it is connected

On an Arduino Nano, I2C is on A4 (SDA) and A5 (SCL). An SSD1306 OLED module runs on 3.3-5 V and has its own regulator and pull-ups on the board, so it connects straight to the Nano's 5V. The order of GND and VCC on the header differs between batches: read the labels on your module before connecting.

The Adafruit_SSD1306 library keeps a 128×64 frame in memory: 1024 bytes of the Nano's 2048 bytes of RAM. If the sketch is large and the screen doesn't start (begin returns false), use U8g2 in page mode.

FAQ

What is the address of a 0.96" OLED?
0x3C. If the address resistor on the back has been moved, 0x3D. The marking 0x78 on the board means the same 0x3C in eight-bit form.
How is connecting to an Uno different?
The wires are the same: SDA to A4, SCL to A5, and on an Uno R3 the same lines are also brought out to the SDA and SCL pins by AREF.
Is a 1.3" screen connected the same way?
The wires are the same, but it more often has an SH1106: the code needs a library for the SH1106 (Adafruit_SH110X or U8g2), otherwise the image is shifted by 2 columns.

You might also need