yt_link
insta_link
fb_link
twitter_link

i2c OLED
page 1/1


i2c OLED with Arduino

Help me by sharing this post



This is a very short example. How to wire up an I2C oled display to the arduino using i2c communication and then display text, numbers, some special cahracters but also some unique logos made with the image2LCD software. Below you have the schematic you need and an example code. Remember to install the i2c OLED librarie below. Read the comments in the code for more or leave a question below.

First, you need an i2c OLED display like this one on this link. This display needs only 2 pins, SCL and SDA which are clock and data.

i2c oled 128X64 Arduino example







PART 1 - Schematic


Ok, make the i2c connections from the Arduino to OLED display as below. The i2c pins of the arduino are A4 for data (SDA) and A5 for clock (SCL). Connect those pins and supply 5V and GND and that's it. Next, download the libraries from below, and uplaod the example code.


scheamtic Arduino 16x2 LCD




PART 2 - Example code


First of all, you need the Adafruit_GFX library and Adafruit_SSD1306 in order to work. For that, go below and downlaod those libraries. They will be a in two .zip files. Open Arduino IDE and go to sketch, include library, add .zip library and select the downlaoded files one by one. Now the libraries are installed. You could downlaod the example code or just copy/paste it from below.

Download Adafruit_GFX library:
Download Adafruit_SSD1306 library:

Download the example code:



/*  OLED i2c Arduino example with unique logos
 * Schematic: https://www.electronoobs.com/eng_arduino_tut52_sch1.php
 * Tutorial: https://www.electronoobs.com/eng_arduino_tut52.php
 */



static const unsigned char PROGMEM  LOGO[] =
{ 
/* 0X00,0X01,0X80,0X00,0X1F,0X00, */
0X00,0X38,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0XFE,0X00,0X00,0X00,0X70,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X01,0XFF,0X0F,0XBF,0XF7,0X7F,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X01,0XFF,0X8F,0X1F,0XFF,0XFF,0XC0,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X03,0XFF,0X8F,0XDF,0XFF,0XFF,0XC0,0X30,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00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,0XEC,0X03,0XFE,0X00,0X1E,0X4E,0X77,0X39,0XDD,0XE0,0X00,
0X00,0X00,0X03,0XE0,0X01,0XFC,0X21,0XFE,0X00,0X1F,0X5E,0X77,0X39,0XF8,0XF8,0X00,
0X00,0X00,0X0B,0XF0,0X03,0XDC,0X3F,0XFE,0X00,0X1F,0XDE,0X77,0X39,0XFC,0XFC,0X00,
0X00,0X70,0X89,0XFF,0XFF,0XFC,0X1F,0XFE,0X00,0X13,0XCE,0X77,0X39,0XDC,0X3C,0X00,
0X02,0X00,0X08,0XFF,0XFF,0XF8,0X1F,0XFE,0X00,0X13,0XCE,0X77,0X39,0XDD,0X8C,0X00,
0X01,0X00,0X0C,0XFF,0XFF,0XF8,0X1F,0XFE,0X00,0X11,0XCE,0X67,0X39,0XDD,0X8C,0X00,
0X01,0X06,0X8D,0XFF,0XFF,0XF8,0X1F,0XFE,0X00,0X11,0XC7,0XE3,0XF1,0XFC,0XFC,0X00,
0X00,0X1B,0X89,0XFF,0XFF,0XF8,0X0F,0XFC,0X00,0X00,0X01,0X80,0XC0,0X00,0X70,0X00,
0X00,0X09,0X8B,0XFF,0XFC,0XF8,0X0F,0XFC,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X0D,0XC0,0X00,0X00,0X00,0X0F,0XFC,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X07,0XC0,0X00,0X00,0X00,0X07,0XFC,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X07,0X80,0X00,0X00,0X00,0X00,0XFC,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X01,0X00,0X00,0X00,0X00,0X00,0X08,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
};


#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>         //download here: https://www.electronoobs.com/eng_arduino_Adafruit_GFX.php
#include <Adafruit_SSD1306.h>     //downlaod here: https://www.electronoobs.com/eng_arduino_Adafruit_SSD1306.php
#define OLED_RESET 5
Adafruit_SSD1306 display(OLED_RESET);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2


#include <DS3231.h>
DS3231  rtc(SDA, SCL);          //use the i2c pins


void setup() {
   
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x32 or 64 from eBay)
  delay(100);
  display.clearDisplay();
  display.display();
  delay(100);
}

void loop() {

  display.clearDisplay();
  display.display();
  
  display.setTextSize(1);    
  display.setCursor(0,0);
  display.setTextColor(WHITE);
  display.println("ELECTRONOOBS"); 
  display.setTextSize(2);    
  display.setCursor(33,8);
  display.setTextColor(WHITE,BLACK);
  display.println("13:22"); 
  display.setTextSize(1);  
  display.setTextColor(WHITE);
  display.println("ABCDEFGHIJKLMNOPQRSTU"); 
  
  display.display();//Finally display the created image

  delay(4000);

  
  display.clearDisplay();
  display.display(); 
  display.setTextSize(1);    
  display.setCursor(45,0);
  display.setTextColor(WHITE);
  display.println("MY LOGO"); 
  display.drawBitmap(0, 8,  LOGO, 128, 31, 1);          
  /*here we print the logo on position 0 on x and 8 on y. The size of the logo is 128 on x
  and 31 on y. the LOGO bytes are defined above and are made with the Image2LCD program*/
  display.display();//Finally display the created image
  delay(3000);

}







Next tutorial →
More tutorials ←

Help me by sharing this post








ADVERTISERS
PCBWAY PCB Manufacturing

PCBWAY Christas PCB Manufacturing

Advanced PCB Manufacturing
Advanced PCB Manufacturing

AFFILATE

Gearbest SG - 700 Satellite Navigation Foldable RC Drone Quadcopter - WHITE 720P WIFI FPV CAMERA
SG - 700 Satellite Navigation Foldable RC Drone Quadcopter - WHITE 720P WIFI FPV CAMERA only $46.99

Gearbest Xiaomi AMAZFIT Heart Rate Smartwatch - BLACK INTERNATIONAL VERSION
Xiaomi AMAZFIT Heart Rate Smartwatch - BLACK INTERNATIONAL VERSION only $89.99

Gearbest FeiLun FT011 2.4GHz Brushless RC Racing Boat - BLACK AND WHITE AND RED
FeiLun FT011 2.4GHz Brushless RC Racing Boat - BLACK AND WHITE AND RED only $96.99