Oled 128×64 SSD1306 display & Arduino – How to get started

Today I received one of those super cheap Oled displays which I bought on Banggood and it was hard to find one single source of help for this tiny display. Maybe this post will help you when you receive yours

The module

To be sure that we are talking about the same module look at the back and check if there is a label saying “www.heltec.cn” and if the module has four connectors labeld VCC, GND, SCL and SDA:

Download library

There are several libraries that might work with this module. I chose u8glib because it seems to offer many features. Download the Arduino library from here and put it into the libraries subfolder of your Arduino working directory. On a Mac this might be a subfolder of Documents. Then (re)start your Arduino IDE. If it worked you should have now a U8glib entry under Sketch > Import Library…

Connect the display

Display Arduino
VCC 5V/3.3V
GND GND
SCL A5
SDA A4

Upload the Source Code

#include <U8glib.h>

U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK);  

void draw() {
  u8g.setFont(u8g_font_unifont);
  u8g.drawStr( 0, 20, "Hello world");

}

void setup() {
}

void loop() {

  u8g.firstPage();  
  do {
    draw();
  } while( u8g.nextPage() );
    delay(1000);
}

Run it

Sources

Now a beer! Did you like this post? It often takes me several hours of my free time to write one. If I was your neighbour would you offer me a beer for the hard work I did for you? The beauty is: beers can be teletransported with a painless donation using Paypal. A beer in a Swiss bar costs about USD $4.80. Or use this affiliate link if you order something on Banggood and I'll get a small kickback. Thank you!
Related:  ESP8266: ESP-201 breakout board review