portfolio

Wiring an OLED I2C

Course Content
Session 1: Introduction to ESP32
Objective: Get familiar with the ESP32 microcontroller and set up the development environment.
0/5
Session 2: Interfacing with Sensors and Displays
Learn how to connect a DHT22 sensor and an OLED display to the ESP32.
0/4
Session 4: Programming the OLED Display
Objective: Write code to display information on the OLED display.
0/4
Session 5: Integrating Sensor Data with OLED Display
Objective: Combine sensor readings with OLED display functionality.
0/1
Session 6: Setup WIFI Capability
0/1
Session 7: Adding a Webserver
0/1
Session 8: Wrap-up
0/1
ESP32 Basics
About Lesson

Wiring an OLED I2C device to an ESP32 is a straightforward process. Here’s a detailed guide on how to connect and configure your OLED display with the ESP32.

Components Needed:

  • ESP32 microcontroller.
  • OLED I2C Display (typically SSD1306, 128×64 or 128×32).
  • Jumper wires.

OLED I2C Pin Layout:

  1. VCC: Power supply (typically 3.3V or 5V).
  2. GND: Ground.
  3. SDA: Serial Data.
  4. SCL: Serial Clock.

Step-by-Step Wiring:

ESP32 Pinout for I2C:

  • SDA: Default is GPIO 21.
  • SCL: Default is GPIO 22.

However, the ESP32 allows you to configure any GPIO pins for I2C, but the above pins are the default ones.

Wiring the OLED to ESP32:

  1. OLED VCC → ESP32 3.3V:

    • Connect the VCC pin of the OLED display to the 3.3V pin on the ESP32 (some OLEDs support 5V, but it’s safer to use 3.3V with the ESP32).
  2. OLED GND → ESP32 GND:

    • Connect the GND pin of the OLED display to one of the GND pins on the ESP32.
  3. OLED SDA → ESP32 GPIO 21 (SDA):

    • Connect the SDA pin of the OLED to GPIO 21 (default SDA pin on ESP32). If using custom pins, connect SDA to your chosen GPIO pin.
  4. OLED SCL → ESP32 GPIO 22 (SCL):

    • Connect the SCL pin of the OLED to GPIO 22 (default SCL pin on ESP32). If using custom pins, connect SCL to your chosen GPIO pin.

Wiring Summary:

  • OLED VCC → ESP32 3.3V
  • OLED GND → ESP32 GND
  • OLED SDA → ESP32 GPIO 21 (SDA)
  • OLED SCL → ESP32 GPIO 22 (SCL)

Notes:

  • Power Supply: Ensure your ESP32 is powered properly, either via USB or another reliable source.
  • I2C Address: Most OLEDs have an I2C address of 0x3C, but it’s good practice to run an I2C scanner if unsure. You can find an I2C scanner script online to confirm the address.
  • SDA and SCL Pins: Although GPIO 21 and GPIO 22 are the default pins for I2C communication, you can define custom pins if needed using the Wire.begin(SDA, SCL); function in the setup.