Adafruit SH110X and two Displays

Hi Guys,

I need to use two little OLEDs for a project that are connected via I2C. I moved the resistor in the back of one of them two the 2nd position and can address each of them seperately.

But as soon as I have two display.begin statements in the code, the first display only shows rubbish and the 2nd remains blank:

#define i2c_Address_1 0x3c 
#define i2c_Address_2 0x3d 
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1   //   QT-PY / XIAO

Adafruit_SH1106G displayA = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Adafruit_SH1106G displayB = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

displayA.begin(i2c_Address_1, true);
displayA.clearDisplay();
displayA.display();

displayB.begin(i2c_Address_2, true);
displayB.clearDisplay();
displayB.display();

displayA.setTextSize(1);
displayA.setTextColor(SH110X_WHITE);
displayA.setCursor(0, 0);
displayA.println("Left Display");
displayA.display();

displayB.setTextSize(1);
displayB.setTextColor(SH110X_WHITE);
displayB.setCursor(0, 0);
displayB.println("Right Display");
displayB.display();

As soon as

displayB.begin(i2c_Address_2, true);

is in the code, the first display only show garbage.

Swapping in code between one and the other is fine. So wiring and display are working.

What am I doing wrong? Is this the wrong approach?

Hi at @hbanko_99 ,

welcome to the arudino forum
well done to post your code as a code-section in your very first posting.

I'm pretty sure that you agree and will follow the way how to solve your problem mimimum 200 minutes faster. This requires to invest 20 minutes of your precious time to read how to speedup solving your problems.

Directly after registering you got presented informations how to speed up solving your problem.
You should really read it.

without knowing more details like what exact type of microcontroller you are using the most likely reason might be a memory problem.

best regards Stefan

Thanks Stefan, already found the solution below my post in the related topics. Too bad that Google failed miserably leading me to post it.

I am out of resources with my Nano on this part. Switched the project over to ESP32-C3. Cheaper than the Aurduino Nano and times more resources and power. It runs already on it. That was easier moving it across platform than I thought!

I thought that was probably the reason, but you did not mention what type of Arduino you were using in your original post. This is one of the things the forum guide reminds you to do, so please read it before you ask your next question.

It is possible for Nano to update 2 OLED displays. It's a little tricky to do with that Adafruit library. Other libraries like U8G2 make it a little easier.