In this tutorial, we’ll learn how to connect 2.42" SSD13093 SPI OLED display with ESP8266. As a development board, we’ll use ESP8266 NodeMCU board.
SPI Pins in ESP8266 NodeMCU Board
ESP provides two SPI ports. However, the ones on the left side (SD1, CMD, SD0, CLK) cannot be used as it’s reserved for flash communication. So, we’ll connect the OLED display through Hardware SPI pins on the right side (D5, D6, D7, D8).
SSD1309 SPI OLED Display Pinouts
The OLED display requires some extra pin connections like DC, Reset, VCC, and GND pins besides the SPI communication pins. As the OLED screen requires 3.3V VCC voltage, the VCC pin should be connected ESP8266 NodeMCU board’s 3.3V pin and the GND pin to the board’s GND. RST and DC pins would be connected to ESP8266 NodeMCU board as it’s explained below.
SSD1309 SPI OLED Display ESP8266 NodeMCU Board Connection
Connect the OLED display to the ESP8266 NodeMCU board according to the connections described in the table below.
+----------------------------+---------------------------+
| ESP8266 NodeMCU Board Pins | SSD1309 OLED Display Pins |
+----------------------------+---------------------------+
| VCC | 3.3V |
| GND | GND |
| D5 (SCLK) | SCK |
| D7 (MOSI) | SDA |
| D8 (CS) | CS |
| D2 | DC |
| D1 | RES |
+----------------------------+---------------------------+
Sample Program Code
For the sample program code, I used u8g2 library to communicate the OLED display.
#include <U8g2lib.h>
U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 15, /* dc=*/ 4, /* reset=*/ 5);
void setup() {
u8g2.begin();
u8g2.setFont(u8g2_font_logisoso16_tf);
}
void loop() {
u8g2.firstPage();
do {
u8g2.drawUTF8(30, 30, "Hello World!");
} while (u8g2.nextPage());
}
Thanks for reading!
Top comments (0)