Skip to content
Free Delivery on Orders Above Rs 999/- Pan-India
Cash on Delivery Available for Orders above Rs.500/- and Upto Rs 3000/-
SAVE more when you BUY more. Upto 30% Off on BULK PURCHASE
GST Invoices for Your Business
Dedicated Technical Support Team
Safely Delivering Genuine Products PAN INDIA

OLED Working And Demo - Part 1

OLED Working And Demo - Part 1
D
Written By Daniel D'Souza
๐Ÿ“… Updated on 17 Jun 2026
โœจ Summarize with AI
โœ… Prompt copied

Organic Light Emitting Diode (OLED) displays are very popularly used in embedded systems

First, let us set up the circuit. Connect the OLED display to the NodeMCU as shown in the diagram below.

OLED VCC โ€“ NodeMCU 3.3V

OLED GND โ€“ NodeMCU GND

OLED SCL โ€“ NodeMCU D1

OLED SDA โ€“ NodeMCU D2

ย 

To begin with the code download and install the library found in the link below.

https://github.com/ThingPulse/esp8266-oled-ssd1306

ย 

For the 1.3 inch OLED display used in this tutorial, the header file we need to use is SH1106.h

ย 

First, let us have a look at displaying text on the OLED.

ย 

//Include the necessary libraries

#include <Wire.h>

#include <SH1106Wire.h>

ย 

//Initialize the display

//I2C address is 0x3c

//SH1106Wire display(I2C_ADDRESS, SDA, SCL);

SH1106Wire display(0x3c, D2, D1);

ย 

void setup()

{

ย // Initialize the display

ย display.init();

ย 

ย //if you want to invert the display

ย display.flipScreenVertically();

}

ย 

void loop()

{

ย //set the font face and font size

ย display.setFont(ArialMT_Plain_24);

ย 

ย //clear the display

ย display.clear();

ย 

ย //center align the text

ย display.setTextAlignment(TEXT_ALIGN_CENTER);

ย 

ย //draw the text on the screen

ย display.drawString(64, 10, โ€œRobocrazeโ€);

ย 

ย //left align the text

ย display.setTextAlignment(TEXT_ALIGN_LEFT);

ย 

ย //draw the text on the screen

ย display.drawString(0, 40, String(millis()));

ย 

ย //update the display to show the text

ย display.display();

ย 

ย delay(10);

}

In the code above the display.drawString() method is used to draw text on the screen. The two arguments to this function are the x and y coordinates in of where you want to place the text given in pixels and the third argument is the text to be drawn.

ย 

This text can be customized in multiple ways. The display.setFont() method sets the font face and size. In the example above we are using ArialMT Plain with font size 24 points. The display.setTextAlignment() method can be used to make the text left, right or centre aligned. Custom fonts can also be designed but that is not covered within the scope of this article.

ย 

The display.flipScreenVertically() method can be used to invert the display in case it is mounted in such a way and is desired to be flipped.

ย 

The display.clear() method clears the screen contents and display.display() method draws all the buffered graphics onto the OLED.

ย 

Let us now look at how to draw images onto the OLED display. The images displayed on the OLED have to be in XBM format. Take an image in BMP format and use the conversion tool provided in the following website to convert it to XBM format.

ย 

Or if you wish to design a small XBM image pixel by pixel you can find a useful tool here

ย 

ย 

Given below is an example image.

ย 

static char img[] = { 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0xf8, 0x1f, 0x0c, 0x30, 0xe6, 0x67, 0xf3, 0xcf, 0x19, 0x98, 0xcc, 0x33, 0xe6, 0x67, 0x30, 0x0c, 0x90, 0x09, 0xc0, 0x03, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01 };

ย 

This is a 16x16 image of the wifi symbol.

ย 

Following code covers drawing images on the OLED display.

ย 

//Include the necessary libraries

#include <Wire.h>

#include <SH1106Wire.h>

ย 

//Initialize the display

//I2C address is 0x3c

SH1106Wire display(0x3c, D2, D1);

ย 

//declare the image

#define WiFi_Logo_width 60

#define WiFi_Logo_height 36

ย 

const uint8_t WiFi_Logo_bits[] PROGMEM = {

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00,

0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,

0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00,

0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,

0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,

0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF,

0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00,

0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C,

0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00,

0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C,

0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00,

0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C,

0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00,

0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C,

0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00,

0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F,

0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00,

0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF,

0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00,

0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,

0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00,

0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

};

ย 

void setup()

{

ย // Initialize the display

ย display.init();

ย 

ย //if you want to invert the display

ย display.flipScreenVertically();

ย 

ย //clear the display

ย display.clear();

ย 

ย //draw the image on the screen

ย display.drawXbm(34, 14, WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits);

ย 

ย //write the buffer to the display

ย display.display();

}

ย 

void loop() {}

ย 

In the code above we see the method display.drawXbm() being used. This takes 5 arguments. First, two are the coordinates of the image in pixels, the next two arguments are the width and height of the image in pixels. Since we are using a 60x36 image hence we pass those to the method. The final argument is the image itself to be drawn onto the display.ย 

Check out the Working and Demo of OLED:

Excerpt

Organic Light Emitting Diode (OLED) displays are very popularly used in embedded systems in this blog we will see OLED Working & its Demo
Prev Post
Next Post

Leave a comment

Please note, comments need to be approved before they are published.

Thanks for subscribing!

This email has been registered!

Shop the look

Choose Options

Edit Option
Back In Stock Notification
Compare
Product SKU Description Collection Availability Product Type Other Details

Choose Options

this is just a warning
Login
Shopping Cart
0 items
FREE SHIPPING!
โ‚น100 OFF
โ‚น200 OFF
โ‚น999
โ‚น2500
โ‚น4900
WhatsApp Chat Chat