Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

ESP32-Powered OLED Display Interface

Image of ESP32-Powered OLED Display Interface

Circuit Documentation

Summary

This document provides a detailed overview of a circuit that integrates an ESP32 microcontroller with an OLED display. The ESP32 is a versatile microcontroller with a wide range of GPIO pins, and it is used here to control a 1.3" OLED display via I2C communication. The OLED display is capable of showing text and graphics, and in this particular setup, it is used to display the message "Hello, world!".

Component List

ESP32 38 PINS

  • Description: A 38-pin ESP32 microcontroller module.
  • Purpose: Acts as the central processing unit of the circuit, controlling the OLED display and handling I2C communication.

OLED 1.3"

  • Description: A 1.3-inch OLED display with four pins: GND, VCC, SCL, and SDA.
  • Purpose: To display text and graphics as commanded by the ESP32 microcontroller.

Wiring Details

ESP32 38 PINS

  • G22: Connected to the SCL pin of the OLED display for I2C clock signal.
  • G21: Connected to the SDA pin of the OLED display for I2C data signal.
  • 3V3: Provides power to the VCC pin of the OLED display.
  • GND: Connected to the GND pin of the OLED display to complete the power circuit.

OLED 1.3"

  • SCL: Receives the I2C clock signal from G22 of the ESP32.
  • SDA: Receives the I2C data signal from G21 of the ESP32.
  • VCC: Powered by the 3V3 pin of the ESP32.
  • GND: Connected to the GND pin of the ESP32 to complete the power circuit.

Documented Code

The following code is written for the ESP32 microcontroller to control the OLED display. It initializes the I2C communication with the display and prints "Hello, world!" on the screen.

#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)
#define OLED_RESET    -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

void setup() {
  // Initialize the I2C communication
  Wire.begin(21, 22);

  // Initialize the OLED display
  if(!display.begin(SSD1306_I2C_ADDRESS, OLED_RESET)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }

  // Clear the buffer
  display.clearDisplay();

  // Display text
  display.setTextSize(1);      // Normal 1:1 pixel scale
  display.setTextColor(SSD1306_WHITE); // Draw white text
  display.setCursor(0,0);     // Start at top-left corner
  display.println(F("Hello, world!"));

  // Update the display with the new text
  display.display();
}

void loop() {
  // Nothing to do here
}

This code is stored in a file named sketch.ino, which is intended to be uploaded to the ESP32 microcontroller. The code makes use of the Adafruit GFX library for graphics operations and the Adafruit SSD1306 library for OLED display control.