i2c SSD1306 Two Oled Displays, works only one at a time

Hello,
I've searched but haven't found anybody with same problem as me.
I'm using Arduino Uno R3 (also tested on Pro Micro, same problem) and two i2c 0.96" SSD1306 OLED Displays, one resoldered to 0x3D address.
i2c scanner sketch finds both 0x3D and 0x3C displays, wiring and resoldering is done fine.
The problem is, that I can initialize only one display at a time. I'm using Adafruit's libraries to drive them -
Wire, Adafruit_SSD1306 and Adafruit_GFX, but I can't manage to make both of my displays work at the same time. Let me picture it for you:

#define OLED_ADDR 0x3C
#define OLED_ADDR2 0x3D

display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
display.clearDisplay();
drawToyotaLogo(); //custom function to draw bitmap
display.display();

= results in display 1 to show toyota logo.

display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR2);
display.clearDisplay();
drawToyotaLogo(); //custom function to draw bitmap
display.display();

= results in display 2 to show toyota logo.

Fine, right?

display1.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
display2.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR2);
display1.clearDisplay();
display1.display();
display2.clearDisplay();
display2.display();

~anything to display

= results only in display 1 to show anything.

When I change the adresses around, only display that was .begin first in the code works.
I can run them like that:

display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR1);
display.clearDisplay();
~
display.display();
display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR2);
display.clearDisplay();
~
display.display();

But everytime I switch displays in the code, they have to be cleared etc. and it makes them blink, which may be annoying at night in the car and I don't want that.

Do you have any clues what can I do? Any sketch from two-display tutorials that I load is not working as it should as well.

128x64 OLED has a 1024 byte buffer in SRAM.

The Uno does not have enough SRAM for two buffers. Try U8g2lib. You can work with smaller buffers but it will be slower.

David.

Thank you David!
I tried u8g2, it worked, but as soon as I put any bitmap in the code I'm out of memory.
I've ordered Mega2560. I hope 8kb of SRAM will be enough for my project.

You can store several bitmaps in Flash memory. Your OLED is monochrome. It only needs 1024 bytes for a whole 128x64 image.

Oh, I have SDCard reader (i mean module) lying around, I'll look for some tutorials how to do it. Thank you!
Edit: I'm dumb. PROGMEM does it all, what the hell was I thinking.

I know I'm doubleposting, but I don't want to open new topic and have one small problem that I have difficulty to find solution on google.
When I use .print function to display float value (DS18B20 temperature), both of my displays show some random pixels / noise in the top-left and bottom-right corners, no matter what they are displaying at the moment. When .print is commented-out in the code noise dissapears. Any tips?

void loop() {
  if (sensors.available())
  {

     OLED_2.clearBuffer(); // clear the internal memory
     OLED_2.setDrawColor(1);
     OLED_2.drawXBMP( 0, 0, 29, 64, fueltemp);

     float temperature = sensors.readTemperature(address);

     OLED_2.setFont(u8g2_font_profont22_mr);
     OLED_2.setCursor(47, 55);
     OLED_2.setDrawColor(1);
     OLED_2.print(temperature);
     OLED_2.print("'C");
     OLED_2.sendBuffer(); // transfer internal memory to the display
 
    sensors.request(address);
     delay(250);
    } 
  }

When I use .print function to display float value (DS18B20 temperature), both of my displays show some random pixels /

Maybe it is a SH1106 display instead.

Oliver

Website (won't link it, it's in Polish) where I bought them says SSD1306, but I'll check to make sure. Thank you for poiting it out.

That looks like an out of memory problem as well. U8g2 in full-buffer mode still consumes a large amount of memory. Have you tried to use page-buffer mode instead?