OLED displays are commonly used in various projects and are typically I2C-based. All ESP32 chips come with at least one I2C port, and some models even support software-based I2C, allowing you to configure multiple devices on the board as I2C peripherals.
In this project, we are Interfacing OLED Display With Indusboard.
Interfacing OLED Display With Indusboard
The IndusBoard is equipped with two I2C ports, enabling the simultaneous connection of multiple sensors, OLEDs, and I2C modules.
For the IndusBoard and most ESP32 chips, I2C pins can be configured for either hardware I2C or software I2C. On the IndusBoard, GPIO pins 8 and 9 are designated for hardware I2C.
You can connect the OLED display as follows:
IndusBoard:
5V → VCC
GND → GND
GPIO 8 → SDA
GPIO 9 → SCL
SSD1306 OLED:
VCC → 5V
GND → GND
SDA → GPIO 8
SCL → GPIO 9
Code
Several libraries are available in the Arduino IDE for interfacing with OLED displays.
In this example, we’ll use the U8g2 library, which offers a variety of fonts and supports different sizes and pixel configurations for OLED displays.
Additionally, U8g2 is compatible with both hardware and software I2C configurations.
Here’s a basic code snippet using the U8g2 library for a 128×64 pixel OLED display connected to hardware I2C pins:
Testing
Now, power the IndusBoard either via the USB port or using a 5V power supply connected to the 5V pin. Once powered on, the OLED display should start showing the text as programmed in the code.