Adafruit_SSD1306.h library is not recognized

I am making a digital thermometer with DS18B20 probe as my first Arduino project. I am using the Adafruit 128x64 OLED display for temperature results but the compiler will not recognize the library for it. I have tried fixing it by searching up my error code in Google and copying what people with similar problems did. I did not succeed so if someone can please help me understand what's going on, that would be awesome!

Here is the code i got and the error message for it.

#include <Wire.h>

#include <OneWire.h>

#include <DallasTemperature.h>

#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>

#include <Adafruit_SSD1306.h>
#include <splash.h>

#define ONE_WIRE_BUS 2                // DS18B20 data wire is connected to input 2
#define OLED_RESET 4                  // Adafruit needs this but we don't use for I2C

DeviceAddress thermometerAddress;     // custom array type to hold 64 bit device address

Adafruit_SSD1306 display(OLED_RESET); // create a display instance
OneWire oneWire(ONE_WIRE_BUS);        // create a oneWire instance to communicate with temperature IC
DallasTemperature tempSensor(&oneWire);  // pass the oneWire reference to Dallas Temperature


void setup()   {

  Serial.begin(9600);

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C address of the display
  display.clearDisplay();                     // clear the display buffer
  display.display();                          // update display

  Serial.println("DS18B20 Temperature IC Test");
  Serial.println("Locating devices...");
  tempSensor.begin();                         // initialize the temp sensor

  if (!tempSensor.getAddress(thermometerAddress, 0))
    Serial.println("Unable to find Device.");
  else {
    Serial.print("Device 0 Address: ");
    printAddress(thermometerAddress);
    Serial.println();
  }

  tempSensor.setResolution(thermometerAddress, 11);      // set the temperature resolution (9-12)
}


void loop() {

  tempSensor.requestTemperatures();                      // request temperature sample from sensor on the one wire bus
  displayTemp(tempSensor.getTempC(thermometerAddress));  // show temperature on OLED display

  delay(500);                                            // update readings every half a second
}

void displayTemp(float temperatureReading) {             // temperature comes in as a float with 2 decimal places

  // set up OLED text size and print the temperature data
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.println("Temp:");

  // show temperature °C
  display.print(temperatureReading, 1);  // rounded to 1 decimal place
  display.print((char)247);              // degree symbol
  display.println("C");
  Serial.print(temperatureReading);      // serial debug output
  Serial.print("°");
  Serial.print("C  ");

  // show temperature °F
  //display.print(DallasTemperature::toFahrenheit(temperatureReading), 1); // rounded to 1 decimal place
  //display.print((char)247);                                              // degree symbol
  //display.println("F");
  //Serial.print(DallasTemperature::toFahrenheit(temperatureReading));     // serial debug output
  //Serial.print("°");
  //Serial.println("F");

  display.display();                    // update the OLED display with all the new text
}


// print device address from the address array
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}
Arduino: 1.8.15 (Windows Store 1.8.49.0) (Windows 10), Board: "Arduino Uno"

In file included from C:\Users\hirde\Desktop\Circuitry projects\projects\digital thermometer\thermometer_code_for_using_DS18B20\thermometer_code_for_using_DS18B20.ino:10:0:

C:\Users\hirde\OneDrive\Documents\Arduino\libraries\Adafruit_SSD1306/Adafruit_SSD1306.h:39:10: fatal error: Adafruit_GFX.h: No such file or directory

 #include <Adafruit_GFX.h>

          ^~~~~~~~~~~~~~~~

compilation terminated.

exit status 1

Error compiling for board Arduino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

@hbajwa Why do users choose to ignore the advice on posting code ?

The easier you make it to read and copy your code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here

If you get errors when compiling please copy them from the IDE using the "Copy error messages" button and paste the clipboard here in code tags

It looks like the Arduino IDE is looking for the library in the wrong folder. You can try importing it manually and see what happens:

#include "C:\Users\filip\OneDrive\Dokumente\Arduino\libraries\Adafruit_SSD1306\Adafruit_SSD1306.h"
#include "C:\Users\filip\OneDrive\Dokumente\Arduino\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp"
When that works, try removing the library from that folder and reinstall it using the Library Manager. You can open the Library Manager by pressing ctrl + shift + i. Then just set type and topic to all and enter Adafruit_SSD1306 in the search bar. It will search and find the library for you, then just install.

Also, the library might be installed but not be compatible with your board (for example because it uses chip specific internal timers). So, try to find out if the library is suitable for your board.

When you see a "No such file or directory" error it almost always means you need to install the library that contains the missing file.

We are accustomed to installing the libraries listed in the #include directives of the sketch. What is a bit more confusing is that libraries may have dependencies on other libraries. That is the case with the Adafruit_SSD1306 library you're using. It has a dependency on the "Adafruit GFX Library". Even though you have the Adafruit_SSD1306 library installed, you don't have the the "Adafruit GFX Library" installed, and this is the cause of your error.

So you only need to install the "Adafruit GFX Library" via the Arduino IDE's Library Manager.

Thanks for your suggestions! I tried to import the library by the directory path but it still failed to recognize the OLED library. I installed a similar library called ACROBOTIC_SSD1306.h but that didnt work either. Then i tried the Adafruit_GFX.h which was dependent on Adafruit_BusIO. That did work!

The libraries i have now imported are:

#include <Adafruit_BusIO_Register.h>
#include <Adafruit_I2CDevice.h>
#include <Adafruit_I2CRegister.h>
#include <Adafruit_SPIDevice.h>

#include <Adafruit_GFX.h>
#include <Adafruit_GrayOLED.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>


#include <Wire.h>

#include <OneWire.h>

#include <DallasTemperature.h>

#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>

#include <C:\Users\hirde\OneDrive\Documents\Arduino\libraries\Adafruit_SSD1306/Adafruit_SSD1306.h>
#include <C:\Users\hirde\OneDrive\Documents\Arduino\libraries\Adafruit_SSD1306/Adafruit_SSD1306.cpp>
#include <splash.h>

The new error message is:

In file included from C:\Users\hirde\Desktop\Circuitry projects\projects\digital thermometer\thermometer_code_for_using_DS18B20\thermometer_code_for_using_DS18B20.ino:23:0:
C:\Users\hirde\OneDrive\Documents\Arduino\libraries\Adafruit_SSD1306/splash.h:5:36: error: redefinition of 'const uint8_t splash1_data []'
 const uint8_t PROGMEM splash1_data[] = {
                                    ^
In file included from C:\Users\hirde\OneDrive\Documents\Arduino\libraries\Adafruit_SSD1306/Adafruit_SSD1306.cpp:54:0,
                 from C:\Users\hirde\Desktop\Circuitry projects\projects\digital thermometer\thermometer_code_for_using_DS18B20\thermometer_code_for_using_DS18B20.ino:22:
C:\Users\hirde\OneDrive\Documents\Arduino\libraries\Adafruit_SSD1306/splash.h:5:23: note: 'const uint8_t splash1_data [704]' previously defined here
 const uint8_t PROGMEM splash1_data[] = {
                       ^~~~~~~~~~~~
In file included from C:\Users\hirde\Desktop\Circuitry projects\projects\digital thermometer\thermometer_code_for_using_DS18B20\thermometer_code_for_using_DS18B20.ino:23:0:
C:\Users\hirde\OneDrive\Documents\Arduino\libraries\Adafruit_SSD1306/splash.h:129:36: error: redefinition of 'const uint8_t splash2_data []'
 const uint8_t PROGMEM splash2_data[] = {
                                    ^
In file included from C:\Users\hirde\OneDrive\Documents\Arduino\libraries\Adafruit_SSD1306/Adafruit_SSD1306.cpp:54:0,
                 from C:\Users\hirde\Desktop\Circuitry projects\projects\digital thermometer\thermometer_code_for_using_DS18B20\thermometer_code_for_using_DS18B20.ino:22:
C:\Users\hirde\OneDrive\Documents\Arduino\libraries\Adafruit_SSD1306/splash.h:129:23: note: 'const uint8_t splash2_data [480]' previously defined here
 const uint8_t PROGMEM splash2_data[] = {
                       ^~~~~~~~~~~~

It has finally accepted the Adafruit_SSD1306.h but now i got a much bigger error message. All i can understand is that it doesn't like the splash.h because the error mentioned splash four times. If i try to take the splash.h away, i get a very long error message. That tells me the splash thing is something useful.

Yes you were right! The Adafruit_GFX.h was dependent on the Adafruit_BusIO_Register.h which pulled a lot of other things along with them. They got the Adafruit_SSD1306.h recognized but i am still not out of the woods yet. I read both of your suggestions and made changes. I replied to philips857 about the result. Thanks!

@hbajwa, because your compiker output indicates IDE 1.8.15, your topic has been moved to a more suitable location on the forum.

Remove these lines. They are unnecessary and will only cause problems.

You had it correct from the start:

#include <Adafruit_SSD1306.h>

ok i did that but the same error message about the splash.h comes up

Remove this line from your sketch:

You didnt read the end of my reply to you. I said if i take away splash.h, it gives me a very big error message. I understand none of that long error message. It is about three times longer than the current one!

Post the error message.

ok here you go. I changed it to // #include <splash.h> and here is what it gives me.

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp: In member function 'void Adafruit_CircuitPlayground::playTone(uint16_t, uint16_t, bool)':
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:238:3: error: 'PLLFRQ' was not declared in this scope
   PLLFRQ = (PLLFRQ & 0xCF) | 0x30;   // Route PLL to async clk
   ^~~~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:238:3: note: suggested alternative: 'PCIFR'
   PLLFRQ = (PLLFRQ & 0xCF) | 0x30;   // Route PLL to async clk
   ^~~~~~
   PCIFR
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:239:3: error: 'TCCR4A' was not declared in this scope
   TCCR4A = _BV(COM4A0) | _BV(PWM4A); // Clear on match, PWMA on
   ^~~~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:239:3: note: suggested alternative: 'TCCR0A'
   TCCR4A = _BV(COM4A0) | _BV(PWM4A); // Clear on match, PWMA on
   ^~~~~~
   TCCR0A
In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.49.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,
                 from c:\program files\windowsapps\arduinollc.arduinoide_1.8.49.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,
                 from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,
                 from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground/utility/Adafruit_CPlay_LIS3DH.h:30,
                 from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground/Adafruit_Circuit_Playground.h:21,
                 from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:30:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:239:16: error: 'COM4A0' was not declared in this scope
   TCCR4A = _BV(COM4A0) | _BV(PWM4A); // Clear on match, PWMA on
                ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:239:16: note: suggested alternative: 'COM0A0'
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:239:30: error: 'PWM4A' was not declared in this scope
   TCCR4A = _BV(COM4A0) | _BV(PWM4A); // Clear on match, PWMA on
                              ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:239:30: note: suggested alternative: 'PWM'
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:240:3: error: 'TCCR4B' was not declared in this scope
   TCCR4B = _BV(PWM4X) | scalebits;   // PWM invert
   ^~~~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:240:3: note: suggested alternative: 'TCCR0B'
   TCCR4B = _BV(PWM4X) | scalebits;   // PWM invert
   ^~~~~~
   TCCR0B
In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.49.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,
                 from c:\program files\windowsapps\arduinollc.arduinoide_1.8.49.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,
                 from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,
                 from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground/utility/Adafruit_CPlay_LIS3DH.h:30,
                 from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground/Adafruit_Circuit_Playground.h:21,
                 from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:30:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:240:16: error: 'PWM4X' was not declared in this scope
   TCCR4B = _BV(PWM4X) | scalebits;   // PWM invert
                ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:240:16: note: suggested alternative: 'PWM'
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:241:3: error: 'TCCR4D' was not declared in this scope
   TCCR4D = 0;                        // Fast PWM mode
   ^~~~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:241:3: note: suggested alternative: 'TCCR0A'
   TCCR4D = 0;                        // Fast PWM mode
   ^~~~~~
   TCCR0A
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:242:3: error: 'TCCR4E' was not declared in this scope
   TCCR4E = 0;                        // Not enhanced mode
   ^~~~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:242:3: note: suggested alternative: 'TCCR0A'
   TCCR4E = 0;                        // Not enhanced mode
   ^~~~~~
   TCCR0A
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:243:3: error: 'DT4' was not declared in this scope
   DT4 = 0;                           // No dead time
   ^~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:243:3: note: suggested alternative: 'DD4'
   DT4 = 0;                           // No dead time
   ^~~
   DD4
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:249:3: error: 'TC4H' was not declared in this scope
   TC4H = hi1;
   ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:249:3: note: suggested alternative: 'PC4'
   TC4H = hi1;
   ^~~~
   PC4
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:250:3: error: 'OCR4C' was not declared in this scope
   OCR4C = lo1; // TOP
   ^~~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:250:3: note: suggested alternative: 'OCR2A'
   OCR4C = lo1; // TOP
   ^~~~~
   OCR2A
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:252:3: error: 'OCR4A' was not declared in this scope
   OCR4A = lo2; // 50% duty
   ^~~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:252:3: note: suggested alternative: 'OCR2A'
   OCR4A = lo2; // 50% duty
   ^~~~~
   OCR2A

exit status 1
Error compiling for board Arduino Uno.

That's completely unrelated to splash.h. The problem is the Adafruit_Circuit_Playground library is for the Adafruit Circuit Playground board and is not compatible with the Arduino Uno board you are compiling for. You won't be able to use that library with the Uno.

So far as I can tell, it doesn't appear you're even using that library in your sketch. Try removing these lines:

#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>

Ok i did now. Before I thought i should add those libraries because they recommended them just as Adafruit_SSD1306.h was from "Include Library". So after deleting the libraries you suggested i tried running it with and without the #include <splash.h>. With it, i get the same error messages as it did about 15 hours ago. Without the splash.h, i get an enormous wall of text for the error message. I dont know what it is trying to tell me.

C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::drawPixel(int, int, unsigned int)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(unsigned char, unsigned char, TwoWire*, signed char, unsigned long, unsigned long)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(unsigned char, unsigned char, TwoWire*, signed char, unsigned long, unsigned long)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(unsigned char, unsigned char, signed char, signed char, signed char, signed char, signed char)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(unsigned char, unsigned char, signed char, signed char, signed char, signed char, signed char)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(unsigned char, unsigned char, SPIClass*, signed char, signed char, signed char, unsigned long)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(unsigned char, unsigned char, SPIClass*, signed char, signed char, signed char, unsigned long)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(signed char, signed char, signed char, signed char, signed char)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(signed char, signed char, signed char, signed char, signed char)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(signed char, signed char, signed char)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(signed char, signed char, signed char)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(signed char)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(signed char)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::~Adafruit_SSD1306()'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::~Adafruit_SSD1306()'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::ssd1306_command1(unsigned char)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::invertDisplay(bool)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::ssd1306_commandList(unsigned char const*, unsigned char)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::ssd1306_command(unsigned char)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::clearDisplay()'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::begin(unsigned char, unsigned char, bool, bool)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::drawFastHLineInternal(int, int, int, unsigned int)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::drawFastVLineInternal(int, int, int, unsigned int)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::drawFastHLine(int, int, int, unsigned int)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::drawFastVLine(int, int, int, unsigned int)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::getPixel(int, int)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::getBuffer()'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::display()'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::startscrollright(unsigned char, unsigned char)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::startscrollleft(unsigned char, unsigned char)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::startscrolldiagright(unsigned char, unsigned char)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::startscrolldiagleft(unsigned char, unsigned char)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::stopscroll()'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp.o (symbol from plugin): In function `Adafruit_SSD1306::drawPixel(int, int, unsigned int)':
(.text+0x0): multiple definition of `Adafruit_SSD1306::dim(bool)'
C:\Users\hirde\AppData\Local\Temp\arduino_build_31640\sketch\thermometer_code_for_using_DS18B20.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino Uno.

Please post your full sketch.

  1. Select Tools > Auto Format from the Arduino IDE's menus. This will make it easier for you to spot bugs and make it easier for us to read.
  2. Select Edit > Copy for Forum from the Arduino IDE's menus.
  3. In a forum reply here, click on the post composer field.
  4. Press Ctrl+V. This will paste the sketch to the post composer.
  5. Move the cursor outside of the code tags before you add any additional text to your reply.
  6. Repeat the above process if your sketch has multiple tabs.
  7. Click the Reply button to post your reply.

Ok i see what you mean. I disabled the Fahrenheit result because i only want Celsius. Here is the most recent code.

#include <Adafruit_BusIO_Register.h>
#include <Adafruit_I2CDevice.h>
#include <Adafruit_I2CRegister.h>
#include <Adafruit_SPIDevice.h>

#include <Adafruit_GFX.h>
#include <Adafruit_GrayOLED.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>

#include <Wire.h>

#include <OneWire.h>

#include <DallasTemperature.h>

#include <Adafruit_SSD1306.h>
#include <Adafruit_SSD1306.cpp>
//#include <splash.h>

/*********************************************************************
  This is an example for reading the temperature out of a
  DS18B20 sensor and displaying the result on an SSD1306
  128x64 OLED display over the I2C bus.
  Temperature can be displayed in degrees C and F.
  Gadget Reboot
*********************************************************************/

#define ONE_WIRE_BUS 2                // DS18B20 data wire is connected to input 2
#define OLED_RESET 4                  // Adafruit needs this but we don't use for I2C

DeviceAddress thermometerAddress;     // custom array type to hold 64 bit device address

Adafruit_SSD1306 display(OLED_RESET); // create a display instance
OneWire oneWire(ONE_WIRE_BUS);        // create a oneWire instance to communicate with temperature IC
DallasTemperature tempSensor(&oneWire);  // pass the oneWire reference to Dallas Temperature

void setup()   {

  Serial.begin(9600);

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C address of the display
  display.clearDisplay();                     // clear the display buffer
  display.display();                          // update display

  Serial.println("DS18B20 Temperature IC Test");
  Serial.println("Locating devices...");
  tempSensor.begin();                         // initialize the temp sensor

  if (!tempSensor.getAddress(thermometerAddress, 0))
    Serial.println("Unable to find Device.");
  else {
    Serial.print("Device 0 Address: ");
    printAddress(thermometerAddress);
    Serial.println();
  }

  tempSensor.setResolution(thermometerAddress, 11);      // set the temperature resolution (9-12)
}

void loop() {

  tempSensor.requestTemperatures();                      // request temperature sample from sensor on the one wire bus
  displayTemp(tempSensor.getTempC(thermometerAddress));  // show temperature on OLED display

  delay(500);                                            // update readings every half a second
}

void displayTemp(float temperatureReading) {             // temperature comes in as a float with 2 decimal places

  // set up OLED text size and print the temperature data
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.println("Temp:");

  // show temperature °C
  display.print(temperatureReading, 1);  // rounded to 1 decimal place
  display.print((char)247);              // degree symbol
  display.println("C");
  Serial.print(temperatureReading);      // serial debug output
  Serial.print("°");
  Serial.print("C  ");

  // show temperature °F
  //display.print(DallasTemperature::toFahrenheit(temperatureReading), 1); // rounded to 1 decimal place
  //display.print((char)247);                                              // degree symbol
  //display.println("F");
  //Serial.print(DallasTemperature::toFahrenheit(temperatureReading));     // serial debug output
  //Serial.print("°");
  //Serial.println("F");

  display.display();                    // update the OLED display with all the new text
}

// print device address from the address array
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

Remove this line from your sketch and try compiling again:

You should never use #include directives for .cpp files. Only use them with .h files.

hmm ok then. I saw other people using that so i though i need to use it. I ran it now. It worked with no red error message. I tried to upload it to the board and the also worked fine but the OLED didn't turn on. I unplugged it from the computer and connected a 9V battery but that didnt work either.

As with anything you'll find on the Internet, there is some good and some bad information out there. It can sometimes be difficult to evaluate the quality of the information. But I think it usually works out in the end.

Even though you haven't achieved complete success yet, this is still some very good progress!

Since we have now resolved your issues with the library installation that was the subject of this topic. My advice is for you to start a new forum topic about the new problem in the "Displays" category. That will bring it to the attention of the people here who are most knowledgeable on the subject matter. If you do that, I will request that you don't continue with a parallel discussion of the display issue here, since parallel discussions (cross-posts) are against the rules here and can end up being problematic.

1 Like