adafruit/Adafruit_SSD1306

Custom i2c pins for ESP32

Closed this issue · 2 comments

ESP32 + SSD1306_i2c
I want to use custom i2c pins. Since wire library has Wire.begin(SDA,SCL,FRQ) or Wire.setPins(SDA,SCL) functions but it is not until within setup() function that I can run them and the wire object has already passed to the Adafruit_SSD1306 constructor, I do not know how to pass custom pin numbers to the instance of wire that I'm passing to the constructor.

I think I have found my solution:

TwoWire myWire = TwoWire(0);
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &myWire, OLED_RESET);

void setup() {
    myWire.begin(13, 14);
    ......

I'll test it on HW tomorrow and will report my result here. Meanwhile I appreciate any comments on this solution.

Worked like a charm, even didn't need to create a custom TwoWire object:

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

void setup() {
    Wire.begin(13, 14);
    ......

But in my case the address suggested by the library was not correct. My display is 128x64 and the address is: 0x3C
Thanks for the great Library and keeping it alive.