ESP32 OLED Display
- Haje Noorjamani

- Mar 9, 2022
- 2 min read
Updated: Apr 6, 2022
In this article, I will tell you about my experience using ESP32 external sensor, BMP280. This project is my fourth ESP32 project and it was given by my lecturers.
Prerequisites
I used Arduino IDE v1.8.19 in Windows 11 64-bit to write the code and upload the code to ESP32, you can download it in here. Just click on download, make sure it the right version and OS, and it will download a zip file. After the download is finished, extract the zip file and open the arduino.exe. It will open the IDE. You might use other IDE, but I recommend you to use Arduino IDE.
I also used some component that I bought at Jaya Plaza, electronic market located in Bandung. But you can get this component on online marketplace.
an ESP32 microcontroller
a Micro-USB type B to USB type A (Male-to-Male)
128x64 OLED LCD Display Module
Four Jumper Wires (Male-to-Male)
Breadboard
Resistor 1K Ω
LED
Step 1: Place and Connect Every Components
Connect OLED GND pin to ESP32 GND pin. Connect OLED VCC pin to ESP32 3V3 pin. Connect OLED SCL pin to ESP32 GPIO22 pin. Connect OLED SDA pin to ESP32 GPIO21 pin.
Step 2: Install Library
Install Adafruit SSD1306 and Adafruit GFX library in Arduino IDE by clicking tools > manage library


Step 4: Code
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
Serial.begin (115200);
if(!display.begin(SSD1306_SWITCHCAPVCC,0x3C)){ // Address0x3D for 128x64
Serial.printin(F("SSD1306 allocation failed"));
for(;;);
}
delay(2000);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 10);
// Display static text
display.printin("Hello, world!");
display.display();
}
void 1oop(){
}Step 5: Output
The output should be like this:


Comments