Multiple 0.96" OLED display's on a UNO, SSD1306 allocation failed 0x3D OLED

Hello, I have read a lot of things about using two 0.96", 128 X 64 OLED display's on a UNO. The most common reply is that there is not enough SRAM on the UNO to support more than one 0.96", 128 X 64 OLED.

I can get two working separately on my UNO but I have to reduce screen width and height.

This will work, but not porperly.

#define SCREEN_WIDTH 85 // OLED display width, in pixels
#define SCREEN_HEIGHT 54 // OLED display height, in pixels

Many threads and website info is dated, and I am wondering if there is any new ways to get two OLED display's working on an UNO.

Is there a way to add SRAM that can be used by the OLED?

Is there a multiplexer that would allow two 128 X 64 OLED to work properly?

I do not know how to post my sketch separately so I have attached an .ino file thinking that may be the proper way to post the code.

I also just pasted the sketch here.

Thanks for any comments!

/* windows 10

  • Arduino I.D.E. Ver. 1.8.13
  • BN: Arduino Uno, VID: 2341, PID: 0043
  • Is there anyway to run two 0.96"
  • 128 X 64 OLED display's at full dimensions
  • on an out of the box UNO, with only Wire.h,
  • Adafruit_SSD1306.h libraries?
  • Memory allocation seems to be the problem.
  • Will a multiplexer solve the problem for
  • two 128 X 64 display's?
    */

#include <Wire.h> // Used for the Adafruit OLED i2c display
#include <Adafruit_SSD1306.h> // Used for the Adafruit OLED i2c display
#include <Adafruit_GFX.h> // Used for the Adafruit OLED i2c display

// OLED definitions
// Actual screen dimensions, 128 X 64 yellow-blue
// if dimensions are reduced both OLED display's work
#define SCREEN_WIDTH 85 // OLED display width, in pixels
#define SCREEN_HEIGHT 54 // OLED display height, in pixels

// OLED definitions
// Actual screen dimensions, 128 X 64 yellow-blue
// This also works
//#define SCREEN_WIDTH 128 // OLED display width, in pixels
//#define SCREEN_HEIGHT 32 // OLED display height, in pixels

// OLED DISPLAY RESET
// reset pin not used but required for library
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)

// OLED DISLPAYS, CREATE AN OBJECT FOR EACH DISPLAY
// display1
Adafruit_SSD1306 display1(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// display2
Adafruit_SSD1306 display2(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

void setup() {

Serial.begin(9600);
while (!Serial) delay(1);

// OLED DISPLAY begin(), SEE SSD1306.cpp approx. line 414

// OLED DISPLAY1, initialize
// OLED begin statement
if(!display1.begin(SSD1306_SWITCHCAPVCC, 0x3C))
{
Serial.println("SSD1306 allocation failed 0x3C OLED");
for(;;); // Don't proceed, loop forever
}

// OLED DISPLAY2, initialize
// OLED begin statement
if(!display2.begin(SSD1306_SWITCHCAPVCC, 0x3D))
{
Serial.println("SSD1306 allocation failed 0x3D OLED");
for(;;); // Don't proceed, loop forever
}

display1.clearDisplay();
display2.clearDisplay();
display1.display();
display2.display();

}// end setup()

void loop() {

// check Serial Monitor timestamp checkbox
Serial.println("loop");

// format display1
display1.setCursor(0,0);
display1.setTextSize(1);
display1.setTextColor(WHITE, BLACK);
display1.print("Display1 3C");
display1.display();

// format display2
display2.setCursor(0,0);
display2.setTextSize(1);
display2.setTextColor(WHITE, BLACK);
display2.print("display2 3D");
display2.display();

delay(800);

display1.clearDisplay(); // Clear display buffer
display2.clearDisplay(); // Clear display buffer
display1.display();
display2.display();

delay(500);

}// end loop()

OLED_Test_program.ino (2.91 KB)

Simple answer is : buy a Zero, Due, ...

Or use U8g2lib library which has different syntax to your Adafruit sketch.
U8g2lib can use small buffers e.g.

U8G2_SSD1306_128X64_NONAME_1_HW_I2C oled1(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
U8G2_SSD1306_128X64_NONAME_1_HW_I2C oled2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

Thank you, yes I have seen posts about that library and the same comments to use a Arduino with more SRAM.

I don't think I can use the two 0.96" OLED display's with the UNO out of the box with Wire.h and the Adafruit_SSD1306.h library, but am still searching for a way.

I think I will check out the library Ug82lib.

Thanks again!

You can't use Adafruit_SSD1306 with two 128x64 on a Uno.

There are text-only SSD1306 libraries that use no buffers at all.

Or U8g2 which can do graphics, text, ... using small buffers.

David.