Go Down

Topic: including SD.h froze OLED screen, what is causing it? (Read 157 times) previous topic - next topic


using pro mini 3.3V with SD card
screen works until including SD library
i think its something simple but very little arduino experience

any ideas?

Code: [Select]

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <SD.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
int time=0;

void setup()   {                
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x64)
  // Clear the buffer.
void loop() {
    display.setCursor(0,0); //init
        display.println("        Speed      ");
        display.print(" ");
        display.print(random(100)+10, DEC);
        //display.print(random(10), DEC);



I assume, you ran out of RAM.
Both libs, Adafruit GFX and SD consume a lot of RAM.

You may try U8glib instead of the Adafruit lib for lesser RAM consumption.



The Adafruit graphics library has a 1024 byte screen buffer. U8glib uses a lot less.

If you are only writing text (or very simple graphics) you can use the text only 1306 library that I am using. It uses about 50 bytes of ram. It is attached below.

Also consider using SdFat instead of SD. It will save you a small amount of ram, several Kb of code and it is also the latest version of the code. SD is based on an older version of SdFat.

Go Up