I2C OLED Panel(128x64)

From GOF_Wiki
Jump to: navigation, search

Contents

Introduction

The I2C OLED(Organic Light-Emitting Diode) Panel is a monochrome 128x64 pixels display module. This display panel works in I2C Mode and has selectable slave address(0x3D/0x3C, default is 0x3D). It has 256-step contrast brightness control, low power consumption, wide viewing angle, wide temperature range, and small size(only about 1" diameter). It requires no backlight and is very readable due to the high contrast of an OLED display.

Module: M2012080101

OLEDss.jpg

Features

Specifications

Mechanic Dimension 31.8mm X22.3mm(without connector)
Communication Protocol I2C
Power Supply Voltage 3V3 for OLED Module from MCU board
5V for logic power matching from MCU I/O(Supply power of MCU Board)
Operating Current Max:33mA ; Typ: 26mA
OLED Module UG-2864HLBEG01,UG-2864HSWEG01
Display Driver IC SSD1306
Number of Pixels 128 × 64
Pixel Pitch 0.17 × 0.17 (mm)
Pixel Size 0.154 × 0.154 (mm)
Operating Temperature -30 to 70°C
Storage Temperature -40 to 80°C
Brightness Typ:100cd/m2; Min:80cd/m2
Display Color White/Light Blue(Monochrome)
RoHS Yes

Pins Definition and Rating

Pins def.jpg

Pin Name Function Note Rating
1 SCL I2C serial clock pin. equal to Master MCU's Logic Level 3V3 - 5V5
2 SDA I2C serial data pin. equal to Master MCU's Logic Level 3V3 - 5V5
3 VIN This pin is not Routed in the OLED Panel. Connet to VIN Pin of Arduino, or left unconnected. Don't care
4 GND Ground Connect to GND pin of Arduino -
5 GND Ground Connect to GND pin of Arduino -
6 5V Supply power for Master MCU, equal to I2C pins Logic Level. Connect to 5V pin of Arduino 3V3 - 5V5
7 3V3 Supply power for Logic(VDD) and DC/DC(VBAT) of OLED Panel Connect to 3V3 pin of Arduino 3V - 3V6

Application Ideas

Example Demonstrations

There are plenty of examples included in the GOFi2cOLED Library, the following are some demostrations.

HeartBeat
DrawChar
DisplayRotation
HorizontalScroll
DrawLine
TestCircle
TestRect
TestTriangle


Cautions

  • Fragile, be gentle!
  • Please install the OLED Panel properly.

Hardware Diagram

OLEDHWD.jpg

Getting Started

Hardware Installation


The I2C OLED Panel(128x64) is easy to get started with; We have GOFi2cOLED Library and plenty of examples, all you need to do is plug-and-play. If you want to program your own application, the following information will give you a start-up. Please refer to UG-2864HLBEG01/UG-2864HSWEG01 and SSD1306 Datasheet for more information.

The main part of I2C OLED Panel(128x64) is UG-2864HLBEG01/UG-2864HSWEG01, which is a 128x64(pixels) Passive Matrix Monochrome Display. UG-2864HLBEG01/UG-2864HSWEG01 is driven by SSD1306 chip, which consists of 128 segments and 64commons, has 256-step brightness control and embeds with contrast control, display RAM and oscillator. The embedded 128 x 64 bits SRAM display buffer store the display data for the 128x64 pixels.

Block Diagram of Display Module
BlokD.jpg

Graphic Display Data RAM (GDDRAM)

The GDDRAM is a bit mapped static RAM holding the bit pattern to be displayed. The size of the RAM is 128 x 64 bits and the RAM is divided into eight pages, from PAGE0 to PAGE7, which are used for monochrome 128x64 dot matrix display, as shown in the following Figure:

Block Diagram of Display Module
GDDRAMpagestructure.jpg


When one data byte is written into GDDRAM, all the rows image data of the same page of the current column are filled (i.e. the whole column (8 bits) pointed by the column address pointer is filled.). Data bit D0 is written into the top row, while data bit D7 is written into bottom row as shown in the following Figure:

Enlargement of GDDRAM (No row re-mapping and column-remapping)
EnlargementGDDRAM.jpg


For mechanical flexibility, re-mapping on both Segment and Common outputs can be selected by software as shown in Figure Block Diagram of Display Moduleclick here.

For vertical shifting of the display, an internal register storing the display start line can be set to control the portion of the RAM data to be mapped to the display (command D3h).

Memory Addressing Mode(Command: 20h)

There are 3 different memory addressing mode in SSD1306: page addressing mode, horizontal addressing mode and vertical addressing mode. This command sets the way of memory addressing into one of the above three modes. In there, “COL” means the graphic display data RAM column.

Page addressing Mode(Command: 0x02, default(reset))

In page addressing mode, after the display RAM is read/written, the column address pointer is increased automatically by 1. If the column address pointer reaches column end address, the column address pointer is reset to column start address and page address pointer is not changed. Users have to set the new page and column addresses in order to access the next page RAM content. The sequence of movement of the PAGE and column address point for page addressing mode is shown in the following Figure:

Address Pointer Movement of Page addressing mode
AddressPointerMovementofPageaddressingmode.jpg

In normal display data RAM read or write and page addressing mode, the following steps are required to define the starting RAM access pointer location:

For example, if the page address is set to B2h, lower column address is 03h and upper column address is 10h, then that means the starting column is SEG3 of PAGE2. The RAM access pointer is located as shown in the following Figure. The input data byte will be written into RAM position of column 3.

Example of GDDRAM access pointer setting in Page Addressing Mode (No row and columnremapping)
ExampleGDDRAMaccesspointersettinginPageAddressingMode.jpg

Horizontal addressing Mode(Command: 0x00)

In horizontal addressing mode, after the display RAM is read/written, the column address pointer is increased automatically by 1. If the column address pointer reaches column end address, the column address pointer is reset to column start address and page address pointer is increased by 1. The sequence of movement of the page and column address point for horizontal addressing mode is shown in the following Figure. When both column and page address pointers reach the end address, the pointers are reset to column start address and page start address (Dotted line in the following Figure.)

Address Pointer Movement of Horizontal addressing mode
AddressPointerMovementofHorizontaladdressingmode.jpg

Vertical addressing Mode(Command: 0x01)

In vertical addressing mode, after the display RAM is read/written, the page address pointer is increased automatically by 1. If the page address pointer reaches the page end address, the page address pointer is reset to page start address and column address pointer is increased by 1. The sequence of movement of the page and column address point for vertical addressing mode is shown in the following Figure. When both column and page address pointers reach the end address, the pointers are reset to column start address and page start address (Dotted line in the following Figure.)

Address Pointer Movement of Vertical addressing mode
AddressPointerMovementofVerticaladdressingmode.jpg

In normal display data RAM read or write and horizontal / vertical addressing mode, the following steps are required to define the RAM access pointer location:

Please refer to 9 COMMAND TABLE and 10 COMMAND DESCRIPTIONS of SSD1306 Datasheet for details.

Slave Address

I2C OLED Panel has to recognize the slave address before transmitting or receiving any information by the I2C-bus. The default slave address is 0x3D, and the slave address can be changed to 0x3C by soldering the SA0 pads on the bottom side of the module. The module will respond to the slave address following by the slave address bit (“SA0” bit) and the read/write select bit (“R/W#” bit) with the following byte format:

b7 b6 b5 b4 b3 b2 b1 b0

0 1 1 1 1 0 SA0 R/W#

SA0 is Slave address bit, it is pulled up to 3V3 by default. You can connect SA0 bit to Ground by soldering SA0 pads.

Write Data

The I2C interface gives access to write data and command into the module. Please refer to following Figure for the write mode of I2C-bus in chronological order. Please refer to 8.1.5 MCU I2C Interface of SSD1306 Datasheet for more information.

I2C-bus data format
I2cdataformat.jpg

To accomplish data write, First slave address must be sent to the module; After the transmission of the slave address, either the control byte or the data byte may be sent. A control byte mainly consists of Co and D/C# bits following by six “0”s.

logic “1”, it defines the following data byte as a data which will be stored at the GDDRAM. The GDDRAM column address pointer will be increased by one automatically after each data write.

That means:if you want to send command, the second byte will be 0x80(GOFi2cOLED_Command_Mode); and if you want to send data, the second byte will be 0x40(GOFi2cOLED_Data_Mode)

Command Mode

So the Command Mode data format will be: Slave Address -> GOFi2cOLED_Command_Mode( 0x80) -> Command/Command sets.

Data Mode

And the Data Mode data format will be: Slave Address -> GOFi2cOLED_Data_Mode( 0x40) -> Data byte/bytes.

Charge Pump Setting(Command: 0x8D)

This I2C OLED Panel is designed to use the internal charge pump regulator to can generate a 7.5V voltage supply for OEL Panel(VCC). So the regulator must be turned on by software command while initializing the Module.

The Charge Pump must be enabled by the following command:0x8D(Charge_Pump_Setting_Cmd) -> 0x14(Charge_Pump_Enable_Cmd) -> 0xAF(GOFi2cOLED_Display_On_Cmd)

Please refer to Charge Pump Regulator of SSD1306 Datasheet for details.

GOFi2cOLED Library

GOFi2cOLED Library provides you an easy start-up. Almost all useful functions are implemented in GOFi2cOLED library. Arduino Wire library needs to be included, so initializing wire library is necessary at the beginning.

Download the GOFi2cOLED Library and unzip it to your ..\Arduino-xx\libraries Folder.

init()

Initializing the I2C OLED Panel: Horizontal Addressing Mode, Normal Display, Deactivate Scroll and Charge Pump enable; Due to the mechanical design, this I2C OLED Panel is also initialized at row re-map and column-remap mode.(The Charge Pump must be enabled). Default slave address is 0x3D.

Syntax

oled.init(SlaveAddress);

Example

#include <Wire.h>
#include <GOFi2cOLED.h>
 
GOFi2cOLED oled;
 
void setup()
{
  oled.init(0x3D);  //initialze  OLED display, default slave address is 0x3D
 
  oled.display(); // show splashscreen
  delay(2000);
 
  oled.clearDisplay();
 
  oled.setTextSize(1);
  oled.setTextColor(WHITE);
  oled.setCursor(0,0);
  oled.println("Hello, world!");
  oled.display();
 
}
 
void loop()
{
 
}

sendCommand()

Basic function, all the command related operation to the OLED Panel can be achieved by sending proper command using sendCommand(command).

Syntax

oled.sendCommand(command);

sendData()

Basic function, all the data related operation to the OLED Panel can be achieved by sending proper data using sendData(data).

Syntax

oled.sendData(data);

setNormalDisplay()

Set the display to normal (non-inverse) mode.

Syntax

oled.setNormalDisplay();

setInverseDisplay()

Set the display to inverse mode.

Syntax

oled.setInverseDisplay();

setCursor()

Set the cursor to X, Y.

Syntax

oled.setCursor(x, y);

setBrightness()

Set contract/brightness of the display.

Syntax

oled.setBrightness(brightness);

setTextSize()

Set the size of the text needed to display.

Syntax

oled.setTextSize( s );

setTextColor()

Set the color of the text needed to display.

Syntax

oled.setTextColor( c ); 
oled.setTextColor( c , bg );


Example

#include <Wire.h>
#include <GOFi2cOLED.h>
 
GOFi2cOLED oled;// default slave address is 0x3D
 
void setup()
{
  oled.init(0x3D);  //initialze  OLED display, default address is 0x3D
 
  oled.display(); // show splashscreen
  delay(1000);
  oled.clearDisplay();
 
  oled.setTextSize(1);
  oled.setTextColor(WHITE);
  oled.setCursor(0,0);
  oled.println("Hello!");
  oled.setTextColor(BLACK, WHITE); // 'inverted' text
  oled.setTextSize(2);
  oled.println("Hello!");
  oled.display();
}
 
void loop()
{
 
}

setTextWrap()

If set, 'wrap' text at right edge of display.

Syntax

oled.setTextWrap( w );

setRotation()

Sets the display rotation.

Syntax

oled.setRotation( r );

getRotation()

Return the display rotation value( 0 - 3 ).

Syntax

oled.getRotation();

setPageMode()

Configures the display to page addressing mode.

Syntax

oled.setPageMode();

setHorizontalMode()

Configures the display to horizontal addressing mode.

Syntax

oled.setHorizontalMode();

setVerticalMode()

Configures the display to vertical addressing mode.

Syntax

oled.setVerticalMode();

clearDisplay()

Clear the buffer for the OLED display. You can see the effect after you use display() function.

Syntax

oled.clearDisplay();

clearArea()

Clear the specific buffer area for the OLED display. You can see the effect after you use display() function.

Syntax

oled.clearArea( x, y, w, h);

width()

Return the value of display width, here is 128.

Syntax

oled.width();

height()

Return the value of display height, here is 64.

Syntax

oled.height();

print() and println()

Those two are inherited from Print.h. Print data to the OLED display as human-readable ASCII text. This command can take many forms, it is the same as serial.print() and serial.println(), please refer to Print

Syntax

oled.print( ); 
oled.println( );

Example

#include <Wire.h>
#include <GOFi2cOLED.h>
 
GOFi2cOLED oled;// default slave address is 0x3D
 
void setup()
{
  oled.init(0x3D);  //initialze  OLED display
 
  oled.display(); // show splashscreen
  delay(2000);
  oled.clearDisplay();
 
  oled.setTextSize(1);
  oled.setTextColor(WHITE);
  oled.setCursor(0,0);
  oled.println("Hello, world!");
  oled.println(-1234); 
  oled.println(3.14159);  
  oled.setTextColor(BLACK, WHITE); // 'inverted' text
  oled.println(3.14159,5);
  oled.setTextSize(2);
  oled.setTextColor(WHITE);
  oled.print("0x"); oled.println(0xDEADBEEF, HEX);
  oled.display();
 
}
 
void loop()
{
 
}

drawPixel()

Draw a pixel on the OLED display.

Syntax

oled.drawPixel( x, y, color);

drawChar()

Draw a 5x7(pixeles) character on the OLED display, if size=1.

Oledchar.jpg

Syntax

oled.drawChar( x, y, c, color, bg, size);

drawLine(), drawFastHLine() and drawFastVLine()

Draw a line.

Drawline.jpg

Syntax

oled.drawLine( x0, y0, x1, y1, color); 
oled.drawFastHLine( x, y, w, color ); 
oled.drawFastVLine( x, y, h, color );

drawRect() or fillRect()

Draw a rectangle or fill a rectangle.

Oledrect.jpg

Syntax

oled.drawRect( x, y,  w, h, color ); 
oled.fillRect( x, y,  w, h, color );

drawRoundRect() or fillRoundRect()

Draw or fill a rounded rectangle.

Oledroundrect.jpg

Syntax

oled.drawRoundRect( x, y,  w, h, radius, color ); 
oled.fillRoundRect( x, y,  w, h, radius, color );

drawTriangle() or fillTriangle()

Draw or fill a triangle.

Oledtriangle.jpg

Syntax

oled.drawTriangle( x0, y0, x1, y1, x2, y2, color); 
oled.fillTriangle( x0, y0, x1, y1, x2, y2, color );

drawCircle() or fillCircle()

Draw or fill a circle.

Oledcircle.jpg

Syntax

oled.drawCircle( x0, y0, r, color); 
oled.fillCircle( x0, y0, r, color );

drawBitmap()

Display a binary bitmap on the OLED Panel.

Syntax

oled.drawBitmap( x, y, *bitmap, w, h, color);

setHorizontalScrollProperties()

Configure the properties of horizontal scroll.

Syntax

oled.setHorizontalScrollProperties(direction, startPage, endPage, scrollSpeed);

activateScroll()

Activate scroll.

Syntax

oled.activateScroll();

deactivateScroll()

Deactivate scroll.

Syntax

oled.deactivateScroll();

How to Create Bitmap

Users can create bitmaps to display easily with the LCD assistant software. First you need to concert the image using any kind of graphics software such as photoshop or Paint and save as a Monochrome Bitmap (bmp), here I use Paint.

OLEDBITMAP.jpg

And use LCD assistant software to select File -> Load image, select the right image and you will see the following options:

OLEDlcdA.jpg

Then select File -> Save output to save the output as a heart.cpp file. And you can use the output directly with our example code.

OLEDbitout.jpg

Schematics

Schematic of I2C OLED Panel

Resources

GOFi2cOLED Library for Arduino 00xx and Arduino 1.xx

SSD1306 Datasheet

UG-2864HLBEG01

UG-2864HSWEG01

LCD assistant

How to buy

I2C OLED Panel(128x64) can be ordered through the GOF store. Its product page is located here

See Also

Licensing

This documentation is licensed under the Creative Commons Attribution-ShareAlike License 3.0 Source code and libraries are licensed under GPL/LGPL, see source code files for details.

Personal tools
Variants
Actions
Navigation
Support
Toolbox