Adafruit_SSD1306.h and SD.h Exceeds memory

I've not even started writing code and i'm out of memory with an OLED display library and an SD card on a NANO. The attached code runs out of ram, see error. I've used both the SD and display but never together. Something looks wrong. Are there any libraries that take up less memory?

Arduino: 1.6.12 (Windows 7), Board: "Arduino Nano, ATmega328"
Sketch uses 14,318 bytes (46%) of program storage space. Maximum is 30,720 bytes.
Global variables use 2,075 bytes (101%) of dynamic memory, leaving -27 bytes for local variables. Maximum is 2,048 bytes.

#include <Adafruit_SSD1306.h>
#include <SD.h>
Adafruit_SSD1306 display(4);

void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C, true);


void loop() {



Try a '1284P board, 16K SRAM, 128K flash.
Here's one of the several form factors I offer boards in, this one is like a Duemilanove (FTDI Chip, vs '16U2 on the Uno) with the bigger memory and 10 more IO pins:

Are there any libraries that take up less memory?

Basically no.
They both take up a lot of memory with buffers. You can trim down the display memory requirements a bit by removing the font table but you might need that. That is the problem with libraries they cover situations that you might not need but you pay for them.

The answer is to write your own drivers or like CrossRoads says get a bigger processor.

Thanks to all.

I was hoping to use the NANO as i'm making a small hand-held stopwatch where one can record lap times of a go cart, save the times, and at any time push a button to plot the times on a graph (all on the OLED). This is working just fine, but i was hoping to save to an SD card so i can plot in excel or save for future reference. Mega or add-ons will not fit in the hand.

Crossroads, you have a very impressive set of projects listed on your website. I sure wish you lived near Northern Alabama. I've been chasing some bugs with a data logger for 6 months...but that's a different story :slight_smile:

U8g2 library is the answer you seek. Instead of one big display buffer, it draws the display in smaller chunks, saving LOTS of RAM.

I have a college friend who lives near northern Alabama, they were just up here for a visit too.
I have 1284's in smaller footprints if that helps, populate headers as needed:

If you're doing a stopwatch, you don't need a per-pixel frame buffer (for graphics), so a text-only library is simpler, and uses less RAM (as long as the font is kept in program memory)

Thanks all.

I have text only libraries, but my goals were to draw a graph on the OLED and i didn't see how to do that with a text library.

I'll look at the U8g2.

Crossroads. Do you also offer you boards on Amazon or Ebay? i have my eye on the one you show.

No, I only offer them thru the forum.
Prices are on my website,
or e-mail me at , MrsCrossroads may answer as/for me. We take payment via paypal.

If you don't need any sort of animation, drawing simple line graphs shouldn't necessarily require a framebuffer.
It depends on what sort of frame rate you need, and how many points per column you need to plot.

Just to say +1 to the u8g lib. Fantastic thing, TONS of fonts to choose from too.