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:
- VCC: Power supply (typically 3.3V or 5V).
- GND: Ground.
- SDA: Serial Data.
- 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:
-
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).
-
OLED GND → ESP32 GND:
- Connect the GND pin of the OLED display to one of the GND pins on the ESP32.
-
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.
-
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.