This circuit consists of an ESP32 microcontroller and a 0.96" OLED display. The ESP32 is a versatile microcontroller with Wi-Fi and Bluetooth capabilities, and it is used here to control the OLED display. The OLED display is likely used to show data or status information from the ESP32. The ESP32 communicates with the OLED display via the I2C protocol, using its dedicated SDA and SCK pins.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Define the screen dimensions
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
// Create an instance of the display
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
// Initialize the display
display.begin(SSD1306_I2C_ADDRESS, OLED_RESET);
display.clearDisplay();
// Set text size and color
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // White text
// Set cursor position
display.setCursor(0, 0);
display.println("Hello, ESP32!");
display.display(); // Show on screen
}
void loop() {
// You can add code here to update the display if needed
}
File Name: sketch.ino
Note: The code initializes the OLED display and prints "Hello, ESP32!" on the screen. The setup()
function is called once when the ESP32 starts, and the loop()
function runs continuously, allowing for further updates to the display if needed.