Error message with RTC codes

Hello everyone,

So, I was trying out a new code I found online at Understanding the Code | DS1307 Real Time Clock Breakout Board Kit | Adafruit Learning System. I keep getting an error message. I followed all the instructions on that website on how to wire the Arduino up, so the hardware is not an issue. The code is:

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
 
#include <Wire.h>
#include "RTClib.h"
 
RTC_DS1307 RTC;
 
void setup () {
    Serial.begin(57600);
    Wire.begin();
    RTC.begin();
 
  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    //RTC.adjust(DateTime(__DATE__, __TIME__));
  }
 
}
 
void loop () {
    DateTime now = RTC.now();
 
    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
 
    Serial.print(" since 1970 = ");
    Serial.print(now.unixtime());
    Serial.print("s = ");
    Serial.print(now.unixtime() / 86400L);
    Serial.println("d");
 
    // calculate a date which is 7 days and 30 seconds into the future
    DateTime future (now.unixtime() + 7 * 86400L + 30);
 
    Serial.print(" now + 7d + 30s: ");
    Serial.print(future.year(), DEC);
    Serial.print('/');
    Serial.print(future.month(), DEC);
    Serial.print('/');
    Serial.print(future.day(), DEC);
    Serial.print(' ');
    Serial.print(future.hour(), DEC);
    Serial.print(':');
    Serial.print(future.minute(), DEC);
    Serial.print(':');
    Serial.print(future.second(), DEC);
    Serial.println();
 
    Serial.println();
    delay(3000);
}

Since I took the code from adafruit's website, I'm assuming the code is right.
But each time I try to run this code, I get the following error message:
sketch_mar08a:6: error: 'RTC_DS1307' does not name a type

I have read other posts where people faced similar problems and the suggested solution was to install the library in the right place. I have read more about installing libraries on the adafruit learning system website and I think that my RTC library is in the right place (it is in the folder 'libraries' in the folder 'Arduino' in Documents). So, I'm not sure what I'm doing wrong here. I was wondering if any one can help?

Thank you!

This tells the compiler to look in project files for the include file: #include "RTClib.h"
This tells the compiler to look in library files for the include file: #include <RTClib.h>

Can you try with the '<' and '>' ?

Hey Caltoa, thanks for your reply. I tried using #include <RTClib.h> but it is still giving me the same error message. Do you know if there is anything else I can try?

Thanks again!

The compiler can't find the library or it can't find the *.h file of the library.
So you must be certain that you have the library in the correct folder.

Go to the folder of your project files.
Is that 'Arduino' in your 'Documents' folder ?
You should see all the folders of all your projects.
One of those folders is called 'libraries', in that folder should be a folder 'RTClib', in that folder should be RTClib.cpp and RTClib.h and a few others.

You may not be looking in the right directory. If you are using a shortcut from the desktop to load the Arduino IDE, right-click on the Arduino icon and select "Properties" from the list and then select the Shortcut tab. The "Target" entry tells you where the actual EXE is located. For example, I installed my IDE on drive E: and named it Arduino105. When I look at Target, it says:

E:/Arduino105/arduino.exe

Therefore, if I look in:

e:/Arduino105/libraries

I see all of the libraries I've installed on my system. Because you mentioned seeing yours on the Desktop, I think you're looking where the shortcut is stored, not the actual EXE directories.

Thank you all! You were right, the RTC library was not in the right folder. I had installed my IDE on drive c, and the RTC library wasn't there. So, I copied it there and the code is running smoothly again.

Thank you all again for your help! Really appreciate it!