High Memory use of SH1106 driver chip

I have used 1.3 Inch I2C Display Module in which driver chip SSH1106 that use Higher memory.The message shows:
Global variables use 1670 bytes (81%) of dynamic memory, leaving 378 bytes for local variables. Maximum is 2048 bytes.
Low memory available, stability problems may occur.

Is there any way to optimize the library or any other replacement library is available?

Maybe.

Bit hard to say without seeing your code, and without knowing exactly which library you are using.

Also, a lot depends on what you're trying to display on it.
Some displays can be made to use text-only libraries.

//This is the sample code which I am using.

#include <Adafruit_ADS1X15.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h>

Adafruit_ADS1115 ads;

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display Height, in pixels

#define OLED_RESET 4

Adafruit_SH1106 oled(OLED_RESET);

// '100%', 26*26 px
const byte Battery_100 [] PROGMEM = {

0x00, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0x00, 0xfc, 0xfc, 0xfc, 0xfc, 0x00, 0xfc, 0xfc, 0xfc, 0xfc,
0x00, 0xfc, 0xfc, 0xfc, 0xfc, 0x02, 0xf8, 0xe0, 0x00, 0x00, 0x00, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f,
0x10, 0x1f, 0x1f, 0x1f, 0x1f, 0x10, 0x1f, 0x1f, 0x1f, 0x1f, 0x00, 0x1f, 0x1f, 0x1f, 0x1f, 0x10,
0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

//Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 144)
const byte batteryfull_LEN = 1;
const byte* batteryfull[1] = {
Battery_100
};

void setup() {
Serial.begin(9600);

oled.begin(SH1106_SWITCHCAPVCC, 0x3C);

oled.clearDisplay();
oled.drawBitmap(100, 2, Battery_100 , 26, 26, WHITE); //battery 100%
}

void loop()
{

} Preformatted text

I am guessing that you are using Adafruit_SH110X library.
But life would be so much easier if people post accurate information.
e.g. link to hardware display. (Ebay sale page)
e.g. name of software library if approved by IDE Library Manager
e.g. link to software library if it is not supported by Manager

If my guess is correct Adafruit_SH110X has a convoluted set of dependent classes which is why you are short of SRAM.

If you want a library with "similar behaviour" to Adafruit_SSD1306 you can try https://github.com/prenticedavid/Adafruit_SH1106_kbv

You still need to be careful with SRAM. e.g. put anonymous strings in Flash
display.print(F("anonymous string"));

David.

1 Like

Have you tried this library...

Let me try and check.

Thank You

You appear to be using a third party library called "Adafruit_SH1106"
You do not say where or how you obtained it.
It is NOT an official Adafruit product.
Nor is my "Adafruit_SH1106_kbv" library.

However your problem is down to your sketch code.
Please learn how to post code properly.

David.

It works.

Problem solved.

Thank You

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.