OLED I2C 128 x 64 px - Arduino connection diagram

OLED I2C 128 x 64 px - Arduino connection diagram

Daniil Zhuk

In small devices, too, it is necessary to display any useful information, while maintaining compact dimensions. Regular screens, like the Nokia 3310, do not provide sufficient resolution, besides, they are not visible in the dark. In various players, electronic cigarettes, and so on, compact OLED displays with a large resolution for their dimensions have long been used - so why are our projects worse?

BRIEF OVERVIEW OF THE MODULE

 

SSD1306 controller-based OLED screens are popular for easy connection, relatively low price and high resolution - for a 0.96-inch screen, the resolution is 128 × 64! In the same Nokia 3310, the resolution is 84 × 48 pixels with a 1.5 ”diagonal.

An important advantage of OLED screens is work without backlighting - each pixel is its own backlight. Due to such a system, the screen consumes very little current (in fact, it can be powered from the pin Arduino). There is one drawback - with constant use, individual pixels begin to fade and lose brightness, but before the onset of this state, you will have time to debug and display everything you can.

OLED I2C Display 1.3 'for Arduino
The display is connected via a high-speed I2C interface (relatively high-speed - up to 400Kbaud) and uses only 2 signal wires. This is another indisputable plus! Despite the fact that the interface is consistent, and even the data in both directions go in one line, on the ordinary Arduino you can achieve about 15-20fps, which is more than enough for projects.

It is worth noting that the display is monochrome - you can’t draw color pictures on it, and two colors are enough for text or graphics.

CONNECTION SCHEME

In total, the display has 4 pins - VCC, GND, SDA, SCL. VCC and GND are connected to VCC and GND Arduino respectively (to be safe, it is better to power the display from pin 3.3V - not on all modules are downconverters), and the data lines are in each version of Arduino on different pins. Uno (Nano, Pro Mini, and other ATMega328 / 168 boards) have SDA - A4, SCL - A5. The Mega - SDA - 20, SCL - 21.

On the 3 revision boards, the interface pins are drawn before the 13 pin on the comb and signed accordingly.

CONNECTING TO ARDUINO IDE
Many libraries are written for the screen, it is supported by the universal U8g2 as well.
To control the display, we need two libraries:

1) Adafruit_GFX_Library

2) Adafruit_SSD1306

Install both libraries in the Arduino IDE, and try to output our favorite “Hello world!”:

#include "SPI.h"
#include "Wire.h"
#include "Adafruit_GFX.h"
#include "Adafruit_SSD1306.h"
#define OLED_MOSI 9
#define OLED_CLK 10
#define OLED_DC 11
#define OLED_CS 12
#define OLED_RESET 13

Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

void setup() {
display.begin(SSD1306_SWITCHCAPVCC);
display.clearDisplay();
display.display();

delay(1000);
display.setTextSize(1); 
display.setTextColor(WHITE);
display.setCursor(0,0); 

display.println("Hello, world!");
display.display();
}

void loop() {
}

Add a comment

* Comments must be approved before being displayed.