ESP8266 ESP-01 with SSD1306 OLED display

This post shows how to connect ESP8266 (ESP-01) module with SSD1306 OLED display where the display used in this project has a resolution of 128×64 Pixel and works in I2C mode. The ESP-01 module has 8 pins only of which 4 can be used as I/O (input/output) pins (GPIO0, GPIO2, RX and TX), the SSD1306 requires 2 pins for the I2C bus and an additional reset pin (if the SSD1306 OLED board has a reset pin).

If you want to see how to use the ESP-01 module for the first time, how to use it with Arduino IDE and how to program (upload sketches) it with Arduino or FT232RL, read the following topic:
ESP8266 WiFi module programming with Arduino UNO board

The SSD1306 OLED used in this project is configured to work in I2C mode, some SSD1306 OLED boards may require a small hardware modifications (to select between SPI mode or I2C mode) such as soldering, placing jumpers …

SSD1306 OLED driver for Arduino IDE:
Adafruit Industries provides a very nice library for the SSD1306 OLED, it can be easily installed using Arduino library manager (Sketch —> Include Library —> Library Manager), or manually by downloading it from the link below and adding it to Arduino libraries folder (C:\Program Files\Arduino\libraries):
Adafruit SSD1306 OLED library

Note that the Adafruit SSD1306 OLED driver supports 3 types: 128×64, 128×32 and 96×16 pixel, we can select between them in the driver header file Adafruit_SSD1306.h. Opening the file with a text editor such as the Arduino IDE gives (scroll down as shown):

Adafruit SSD1306 OLED driver modifiy

I commented the default display type #define SSD1306_128_32 and uncommented #define SSD1306_128_64 because I’m using 128×64 pixel display (0.96″).

We need an other library named Adafruit GFX (graphics library) which can be installed through Arduino library manager or manually by downloading it from the link below:
Adafruit GFX library

ESP8266 ESP-01 SSD1306 OLED I2C mode circuit

Hardware Required:
The components listed below are required for this project.

  • ESP8266 ESP-01 module
  • SSD1306 OLED display
  • AMS1117 3V3 voltage regulator (LM1117 3.3V)
  • 2x10uF capacitor
  • 0.1uF (100nF) ceramic capacitor
  • 5V source
  • Breadboard
  • Jumper wires

Interfacing ESP-01 module with SSD1306 OLED circuit:
ESP8266 ESP-01 with SSD1306 OLED board circuit is shown below.

ESP-01 ESP8266 SSD1306 OLED in I2C mode

(All grounded terminals are connected together)

The AMS1117 3V3 regulator is used to feed the ESP-01 module with 3.3V form the 5V source, its role is to step down the 5V into 3.3V, because the operating voltage of the ESP-01 is from 2.5V to 3.6V.

The SDA and SCL lines of the I2C bus come from GPIO2 and GPIO0 of the ESP-01 module (respectively), they are connected to SDA and SCL (SCK) pins of the SSD1306 board.
SSD1306 board reset pin (RES) is connected to ESP-01 module TX pin which is GPIO1.

Arduino code for ESP8266:
Project code is Adafruit library example code (ssd1306_128x64_i2c). I added Wire.begin(2, 0); to configure the I2C bus pins. SDA is set to GPIO2 and SCL to GPIO0.
The default clock frequency is 100kHz, for 400kHz clock uncomment line number 65 (L for long):
//Wire.setClock(400000L);

Full code is below:

ESP-01 module + SSD1306 OLED display video:


Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

3 thoughts on “ESP8266 ESP-01 with SSD1306 OLED display”

  1. Thank you for the excellent write-up. Very useful. One small typo – you say “The SDA and SCL lines of the I2C bus come from GPIO2 and GPIO1” but it’s actually GPIO0 and GPIO2 as is shown in your correct diagram and code. Just posting for the next person who finds this tutorial.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top