Adsense HTML/JavaScript

Tuesday, October 26, 2021

arduino-esp32, drive SSD1306 I2C OLED with ESP32/C3/S2 using esp8266-oled-ssd1306 library


With arduino-esp32 2.0.0 installed on Arduino IDE, this post run examples on ESP32-DevKitC V4/ESP32-S2-Saola-1/ESP32-C3-DevKitM-1 to drive SSD1306 I2C OLED, using esp8266-oled-ssd1306 library.


Open Library Manager in Arduino IDE, install "ESP8266 and ESP32 OLED driver for SSD1306 displays" by ThingPulse, currently 4.2.1. (esp8266-oled-ssd1306)


In the library examples, OLED display is initialized using pre-defined SDA and SCL based on your board's pins_arduino.h.
SSD1306Wire display(0x3c, SDA, SCL);   // ADDRESS, SDA, SCL


for ESP32 Dev Module:
SDA:  21
SCL:  22

for ESP32S2 Dev Module:
SDA:  8
SCL:  9

for ESP32C2 Dev Module:
SDA:  8
SCL:  9

* But on ESP32-C3-DevKitM-1 I used to test for ESP32C2 Dev Module, GPIO8 is connected to onboardRGB LED. (refer to the post "Drive ESP32-C3-DevKitM-1/ESP32-S2-Saola-1 on-board RGB LED (WS2812) in Arduino Framework") So I re-allocate to:
SDA:  19
SCL:  18

same GPIOs assigned in "ESP32-C3/MicroPython + SSD1306 I2C OLED".
SSD1306Wire display(0x3c, 19, 18);   // ADDRESS, SDA, SCL

Also connect ESP32 dev board's 3V3 and GND to SSD1306 VCC and GND.

No comments:

Post a Comment