fatal error: Adafruit_SSD1306.h: No such file or directory

I’m using Windows 10 and IDE 1.8.5
The compiler can’t find Adafruit_SSD1306.h
I can see from file explorer that it is in Arduino\Libraries\Adafruit_SSD1306-master
and Sketch - Include Libraries shows it in the list under Recommended Libraries. Please help my compiler find it :slight_smile:

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

//#define OLED_RESET 4
Adafruit_SSD1306 display(4);
File myFile;

void setup()   {   


pinMode(10, OUTPUT);
  

Serial.begin(9600);

  myFile = SD.open("testfile.txt");
  if (myFile) {
    Serial.println("testfile.txt:");
 
    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

  
  Serial.begin(9600);

   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  
  // Clear the buffer.
  display.clearDisplay();

String stuffToDisplay = "Rectal Bum";
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  //display.println("Hello, world!");
  //display.setTextColor(BLACK, WHITE); // 'inverted' text
  //display.println(3.141592);
  //display.setTextSize(2);
  //display.setTextColor(WHITE);
  //display.print("0x"); display.println(0xDEADBEEF, HEX);
  display.println(stuffToDisplay);
  display.display();
  delay(2000);
  display.clearDisplay();

  






}


void loop() {
  
}
Arduino: 1.8.5 (Windows 10), Board: "Arduino Duemilanove or Diecimila, ATmega328P"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\steve\AppData\Local\Arduino15\packages -hardware F:\Documents\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\steve\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries F:\Documents\Arduino\libraries -fqbn=arduino:avr:diecimila:cpu=atmega328 -vid-pid=0X2341_0X0042 -ide-version=10805 -build-path C:\Users\steve\AppData\Local\Temp\arduino_build_567031 -warnings=none -build-cache C:\Users\steve\AppData\Local\Temp\arduino_cache_854820 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Users\steve\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2 -prefs=runtime.tools.arduinoOTA.path=C:\Users\steve\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.1.1 -prefs=runtime.tools.avrdude.path=C:\Users\steve\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -verbose F:\Documents\Arduino\Reder\Reder.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\steve\AppData\Local\Arduino15\packages -hardware F:\Documents\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\steve\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries F:\Documents\Arduino\libraries -fqbn=arduino:avr:diecimila:cpu=atmega328 -vid-pid=0X2341_0X0042 -ide-version=10805 -build-path C:\Users\steve\AppData\Local\Temp\arduino_build_567031 -warnings=none -build-cache C:\Users\steve\AppData\Local\Temp\arduino_cache_854820 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Users\steve\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2 -prefs=runtime.tools.arduinoOTA.path=C:\Users\steve\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.1.1 -prefs=runtime.tools.avrdude.path=C:\Users\steve\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -verbose F:\Documents\Arduino\Reder\Reder.ino
Using board 'diecimila' from platform in folder: C:\Users\steve\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21
Using core 'arduino' from platform in folder: C:\Users\steve\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21
Detecting libraries used...
"C:\Users\steve\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR   "-IC:\Users\steve\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\steve\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\standard" "C:\Users\steve\AppData\Local\Temp\arduino_build_567031\sketch\Reder.ino.cpp" -o "nul"
"C:\Users\steve\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR   "-IC:\Users\steve\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\steve\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\standard" "-IC:\Users\steve\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire\src" "C:\Users\steve\AppData\Local\Temp\arduino_build_567031\sketch\Reder.ino.cpp" -o "nul"
"C:\Users\steve\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR   "-IC:\Users\steve\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\steve\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\standard" "-IC:\Users\steve\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire\src" "C:\Users\steve\AppData\Local\Temp\arduino_build_567031\sketch\Reder.ino.cpp" -o "C:\Users\steve\AppData\Local\Temp\arduino_build_567031\preproc\ctags_target_for_gcc_minus_e.cpp"
F:\Documents\Arduino\Reder\Reder.ino:4:30: fatal error: Adafruit_SSD1306.h: No such file or directory

 #include <Adafruit_SSD1306.h>

                              ^

compilation terminated.

Using library Wire at version 1.0 in folder: C:\Users\steve\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire 
exit status 1
Error compiling for board Arduino Duemilanove or Diecimila.

Where is the file Adafruit_SSD1306.h located on your computer?

it’s in f:\Documents\Arduino\Libraries\Adafruit_SSD1306-master

[u]L[/u]ibraries != [u]l[/u]ibraries

(deleted)

Will the compiler find "Adafruit_SSD1306" in a folder called "Adafruit_SSD1306-master"?

I think PieterP might be on the right track. Try renaming the folder f:\Documents\Arduino\Libraries to libraries (lower case l).

adwsystems: Will the compiler find "Adafruit_SSD1306" in a folder called "Adafruit_SSD1306-master"?

Yes. The only time the library folder name not matching the header file name matters is if you have multiple libraries that contain a file with a name matching the #include directive. In that case, one of the factors the Arduino IDE uses to determine which library gets preference is whether the folder name matches the header file name. In this case, I think it's very unlikely that there are two libraries installed which have a file named Adafruit_SSD1306.h and certainly that is not the cause of the "No such file or directory" error.

ok it's in f:\Documents\Arduino\libraries\Adafruit_SSD1306-master with a small l. I misread the path when I typed it here.

I posted in the wrong topic then tried to delete it but can't find a way of doing that so deleted the content and left an apology.

I don't think there is a duplicate file anywhere and have set the PC off searching...

I've fixed it...somehow the filename had acquired a space at the end of the name that required rather good eyesight to spot!

I'm now out of memory on my Atmega328P though

Sketch uses 19194 bytes (62%) of program storage space. Maximum is 30720 bytes.

Global variables use 2263 bytes (110%) of dynamic memory, leaving -215 bytes for local variables. Maximum is 2048 bytes. Not enough memory;

It's certainly the Adafruit library using most of the space. Somehow I need to slim it down without breaking it! I'm just using basic text string and value printing, no snazzy graphics.

stevehunt100: It's certainly the Adafruit library using most of the space.

It does use a fair bit of memory.

I’m using the same version of the Arduino IDE (1.8.5), the same version of Arduino AVR boards (1.6.21), and the latest release of the Adafruit libraries, but when I compile the code you posted I get this:

Using library Wire at version 1.0 in folder: C:\Program Files (x86)\ArduinoIDE\arduino-1.8.5\hardware\arduino\avr\libraries\Wire 
Using library Adafruit_SSD1306 at version 1.1.2 in folder: E:\electronics\arduino\libraries\Adafruit_SSD1306 
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\ArduinoIDE\arduino-1.8.5\hardware\arduino\avr\libraries\SPI 
Using library Adafruit_GFX_Library at version 1.2.3 in folder: E:\electronics\arduino\libraries\Adafruit_GFX_Library 
Using library SD at version 1.1.1 in folder: C:\Program Files (x86)\ArduinoIDE\arduino-1.8.5\libraries\SD 
Sketch uses 18386 bytes (59%) of program storage space. Maximum is 30720 bytes.
Global variables use 1744 bytes (85%) of dynamic memory, leaving 304 bytes for local variables. Maximum is 2048 bytes.

Are you compiling different code?

Note that using String wastes a lot of memory. If you use a string instead (null terminated char array) it significantly reduces the program storage space usage:

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

//#define OLED_RESET 4
Adafruit_SSD1306 display(4);
File myFile;

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

  Serial.begin(9600);

  myFile = SD.open("testfile.txt");
  if (myFile) {
    Serial.println("testfile.txt:");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

  Serial.begin(9600);

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  // Clear the buffer.
  display.clearDisplay();

  char stuffToDisplay[] = "Rectal Bum";
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  //display.println("Hello, world!");
  //display.setTextColor(BLACK, WHITE); // 'inverted' text
  //display.println(3.141592);
  //display.setTextSize(2);
  //display.setTextColor(WHITE);
  //display.print("0x"); display.println(0xDEADBEEF, HEX);
  display.println(stuffToDisplay);
  display.display();
  delay(2000);
  display.clearDisplay();
}

void loop() {
}
Sketch uses 17808 bytes (57%) of program storage space. Maximum is 30720 bytes.
Global variables use 1744 bytes (85%) of dynamic memory, leaving 304 bytes for local variables. Maximum is 2048 bytes.

F() macro can help reduce SRAM memory usage:

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

//#define OLED_RESET 4
Adafruit_SSD1306 display(4);
File myFile;

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

  Serial.begin(9600);

  myFile = SD.open(F("testfile.txt"));
  if (myFile) {
    Serial.println(F("testfile.txt:"));

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println(F("error opening test.txt"));
  }

  Serial.begin(9600);

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  // Clear the buffer.
  display.clearDisplay();

  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  //display.println("Hello, world!");
  //display.setTextColor(BLACK, WHITE); // 'inverted' text
  //display.println(3.141592);
  //display.setTextSize(2);
  //display.setTextColor(WHITE);
  //display.print("0x"); display.println(0xDEADBEEF, HEX);
  display.println(F("Rectal Bum"));
  display.display();
  delay(2000);
  display.clearDisplay();
}

void loop() {
}
Sketch uses 18614 bytes (60%) of program storage space. Maximum is 30720 bytes.
Global variables use 1686 bytes (82%) of dynamic memory, leaving 362 bytes for local variables. Maximum is 2048 bytes.

That's really helpful Pert. I downloaded the current adafruit library and overwrote the files in my library and now compile with only 85% dynamic memory used, like you :) I guess they slimmed down the library in a recent version?

I'll also have a go with string and F thanks. Gotta get this thing slimmed down as there's 600 lines of code to paste in from the main project! The attached code was just to test the SD card reader using the oled to display the file contents (I haven't completed the code to display it yet...had to make it fit in memory first)

Thanks again

Note that the compiler only lists static memory usage. It doesn't say anything about local variables due to function calls, or dynamic memory usage due to things like Strings. If you're not careful, your program will start crashing.

I'd recommend you get a more capable microcontroller. Teensy boards are small, cheap, and have plenty of RAM to drive displays etc.

Alternatively, you could try refreshing the display in tiles. Keeping all 64x128 pixels in memory requires a buffer of 1KiB of RAM, that's 50% of what's available.