Using SSD1306 with external RAM

Hi there,

I am currently using the SSD1306 128x68 OLED display with my Arduino Pro Mini. I am running into RAM issues and I am aware that the display requires 1024 bytes of RAM to function. I purchased a Microchip 23LC1024 external RAM IC which I would like to use with this application. I am aware of how to read and write from the external RAM and I would like to write and read the 1024 byte display buffer to and from the external RAM chip instead of the classic 2KB onboard RAM. P.S I am using the Adafruit_SSD1306 and GFX libraries.

Is there anyway to access the 1024 B buffer in my Arduino code.

A simple video of how to use the External RAM: Extending Arduino Uno RAM - YouTube

Funny, I was thinking about the exact same thing a short time ago. Conceptually you'd need to fetch a byte or range of bytes (based on how much internal RAM you can spare) from the external RAM and then send those to the SSD1306. You'd need to modify the library so that writes to the frame buffer go to the external RAM instead of internal RAM. A lot of those writes involve array-style addressing and that obviously won't work with external RAM so you'd have some development work to do. You'll also need to modify reads from the frame buffer in the same way. Finally, you'll need to modify the code that updates the display from the frame buffer so that it fetches data from external RAM and sends it to the display. Of course this won't be as fast as using internal RAM. You could probably improve the performance with an interrupt driven routine for getting data from external RAM via SPI and then sending it to the display via I2C.

I was also thinking that this data transfer might perform reasonably well if it could be done using DMA but that's outside the realm of Arduino at that point.

U8g2 could be a solution. It offers two RAM saving modes: U8x8 (almost no RAM required) and U8g2 page mode (128 Bytes required). So, with u8g2 you do not need any external extra RAM.

Oliver

Thanks MicrocontrollerGuy and Oliver.

MCUGuy: Do you know what part of the library I need to edit exactly. I am new to the C++ language and would like to do minimal library editing if possible. Is there no way to do this from the IDE.

Oliver: Do you know how much RAM this library takes up and can it use bitmaps?

Thanks

Hi

U8g2 HelloWorld.ino Example page buffer mode and hardware SPI with SSD1306 compiled for Uno requires 572 Bytes RAM (out of 2048).

In page buffer mode you can display bitmaps of any size without problems.

Oliver

Is your library available using the I2C bus as I am only seeing usage using SPI.

Why only 512 bytes where I see some confs using 128 bytes. I am not concerned about speed as I only need to update the display every second.

Thanks!

and what is the difference between 128X64_NONAME and 128X64_VCOMH0?

Hi

Is your library available using the I2C bus as I am only seeing usage using SPI.

I2C is supported, see the Examples and Wiki. Ensure to use HW_I2C if possible

and what is the difference between 128X64_NONAME and 128X64_VCOMH0?

VCOMH0 is a special setup to maximize contrast range if you use u8g2.setContrast command. However this is not supported by all OLEDs. Try to start with the NONAME device first.

Why only 512 bytes where I see some confs using 128 bytes.

Not exactly sure, what you mean, but u8g2 page buffer will use 128 bytes for your display (instead of 1024). Other bytes are used by u8g2 itself, by SPI/Wire libraries and by the Arduino environment.

Oliver

Thanks for your help so far.

By 128 bytes, I was wondering what is the minimum amount of RAM which I can use (using bitmaps) if I do not need a fast frame rate (1 Hz) using your library.

If graphics is required, you can choose between one page (128 bytes), two pages (256 bytes) and a full frame buffer (1024 bytes).

Oliver

I have a string array with date, time, notifications .etc. Is there anyway to use indices in this array in the DrawStr() function

MCUGuy: Do you know what part of the library I need to edit exactly. I am new to the C++ language and would like to do minimal library editing if possible.

In that case I think it's better for you to use the other library that olikraus mentioned. I listed the parts of the library that I could think of that would need to be changed. It would require programming skill and you'd also need to write the interface routines for the external RAM.

ddesousa:
I have a string array with date, time, notifications .etc. Is there anyway to use indices in this array in the DrawStr() function

This is not a library question, but answer should be yes.

Oliver

A different thought, the Pro Mini dimensions are 0.7" x 1.3":
https://www.arduino.cc/en/pmwiki.php?n=Main/ArduinoBoardProMini

If you have space for 1.1" x 2.8" (this includes OLED display), then Lolin ESP32 with OLED for <10$ might be an option. That has 160MHz (20/10 times the Pro Mini clock speed, and 32bit CPU), 520KB sram instead of 2KB, is programmable with Arduino IDE and uses standard SSD1306 library for the OLED. So if size and price are no blocker, it may be an alternative for you, see this thread:

Thanks for the thoughts Herman. Unfortunately, I do not have that kind of space!

Oliver, the library works great! Exactly like the Adafruit library works once I found the u8g2.print function.
One problem, this lib seems to be taking up a lot of Flash memory now. Any solutions?
Also, is there anyway to speed it up. I know I said I only need to update to be every second but I also need to update quickly so Im not holding up other peripherals.

One problem, this lib seems to be taking up a lot of Flash memory now. Any solutions?

I have an FAQ entry for this:

For more specific comments, please post your code.

Oliver