Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Powered OLED Display Interface

View and Edit Project In Cirkit DesignerImage 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

OLED 1.3"

Wiring Details

ESP32 38 PINS

OLED 1.3"

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.