[solved] oled + sd = too much ram ?

Hi! I’m pretty new to arduino.
After doing some examples I want to realize a small project combining different boards and libraries.

The plan is to read out a DHT22, store the information on an SD-card and display a small graph on an oled.
However, using <DHT.h>, <SD.h> and “Adafruit_SSD1306.h” in a sketch is already using >106% of dynamic storage.

I took a short look into adapting the libraries so only needed features would stay, but after much fiddling I got something like 102%…

Is there a way to realize this project on an atmega328 (with an Arduino Uni R3 Board from Elegoo) ?
Perhaps by using different libraries, a different storage or writing something on my own.
Or should I just use an atmega644 instead?

Here is the sketch:

#include <DHT.h>
#include <SD.h>
#include "Adafruit_SSD1306.h"

#define PINS_ON_OLED 4
#define D_SD_PIN 4
#define D_DHT_PIN 2

Adafruit_SSD1306 display(PINS_ON_OLED);
DHT dht(D_DHT_PIN, DHT22);

char str[20];
int Luftfeuchtigkeit, Temperatur;

void setup() {
  pinMode(10, OUTPUT);

  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x64 if SA0=GND, else 0x3D)

  if (!SD.begin(D_SD_PIN)) {
    while (1);

  dht.begin(); //DHT22 Sensor starten

void loop() {

  Luftfeuchtigkeit = dht.readHumidity(); //die Luftfeuchtigkeit auslesen und unter „Luftfeutchtigkeit“ speichern
  Temperatur = dht.readTemperature(); //die Temperatur auslesen und unter „Temperatur“ speichern
  snprintf(str, 20, "%3d.%02dC, %3d.%02d%%", Temperatur / 100, abs(Temperatur % 100), Luftfeuchtigkeit / 100, abs(Luftfeuchtigkeit % 100));

  File dataFile = SD.open(F("datalog.txt"), FILE_WRITE);

  if (dataFile) {
  else {
    Serial.println(F("error opening datalog.txt"));

  display.setCursor(0, 0);



And also the list of components I use (Sorry for the amazon link. I couldn’t find datasheets):
OLED: https://www.amazon.de/AZDelivery-Display-Arduino-Raspberry-gratis/dp/B01L9GC470/ref=sr_1_1?ie=UTF8&qid=1521853773
SD: Arduino SD card Module - Geeetech Wiki (similar, but from COM-FOUR)
SHT22: https://cdn-shop.adafruit.com/datasheets/Digital+humidity+and+temperature+sensor+AM2302.pdf

Here is an example of application with Oled and SD card on an arduino DUE, works fine thanks to the
96 KB memory and a 84 MHz clock:

There is a low memory version of the SSD1306 library, which amazingly I found with a Google search on;

'Arduino low memory ssd1306 library'

@srnet to unleash the true power of google search requests, you need to be able to do 2 things:

  1. Think of the correct search terms. (thanks for that!)
  2. Recognize a search hit as the answer to your question.

(it also doesn't help that google seems to be sorting the result depending on your browser-history)

When I googled that, first hit was something for an sduino, which doesn't seem work on a normal setup (?).
Then there was ASCI-Only ssd1306-library here: https://github.com/greiman/SSD1306Ascii
Since I want to draw a small graph, this seemed to be the wrong solution.

However, then I noticed that you can easily make your own fonts.
After changing the library, so the 1px-gap between chars vanished and adding a custom font with 1px wide vertical bars, I can now easily display a bar-chart by "writing" characters for example by \x20, \x21.

By switching between the custom font and a regular font, I can also write normal text on the display.
Drawing the charts is a bit slow (~500ms), but this is a different problem.

Now with the ASCI-Only OLED-library, only ~60% storage is needed and I can focus on progamming parts.
Thanks for the help. ^^

Since I want to draw a small graph, this seemed to be the wrong solution.

Did you mention the requirement to draw a graph ?