Real Time Clock with Arduino Uno Board: SetTime Error

Hey team,

So I’m trying to use an Extremely Accurate RTC with an Arduino Uno board. I’m following all of the directions found here (in terms of wiring and setting up libraries):’s_Extremely_Accurate_Real_Time_Clock
. When I run the SetTime code (below), which is straight from the DS1307RTC library, I get a long list of errors.

#include <Wire.h>
#include <Time.h>
#include <DS1307RTC.h>

const char *monthName[12] = {
  "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"

tmElements_t tm;

void setup() {
  bool parse=false;
  bool config=false;

  // get the date and time the compiler was run
  if (getDate(__DATE__) && getTime(__TIME__)) {
    parse = true;
    // and configure the RTC with this info
    if (RTC.write(tm)) {
      config = true;

  while (!Serial) ; // wait for Arduino Serial Monitor
  if (parse && config) {
    Serial.print("DS1307 configured Time=");
    Serial.print(", Date=");
  } else if (parse) {
    Serial.println("DS1307 Communication Error :-{");
    Serial.println("Please check your circuitry");
  } else {
    Serial.print("Could not parse info from the compiler, Time=\"");
    Serial.print("\", Date=\"");

void loop() {

bool getTime(const char *str)
  int Hour, Min, Sec;

  if (sscanf(str, "%d:%d:%d", &Hour, &Min, &Sec) != 3) return false;
  tm.Hour = Hour;
  tm.Minute = Min;
  tm.Second = Sec;
  return true;

bool getDate(const char *str)
  char Month[12];
  int Day, Year;
  uint8_t monthIndex;

  if (sscanf(str, "%s %d %d", Month, &Day, &Year) != 3) return false;
  for (monthIndex = 0; monthIndex < 12; monthIndex++) {
    if (strcmp(Month, monthName[monthIndex]) == 0) break;
  if (monthIndex >= 12) return false;
  tm.Day = Day;
  tm.Month = monthIndex + 1;
  tm.Year = CalendarYrToTm(Year);
  return true;

The errors I receive include:

In file included from SetTime.ino:3:
C:\Documents and Settings\Lab\My Documents\Arduino\libraries\DS1307RTC/DS1307RTC.h:17: error: ‘time_t’ does not name a type
C:\Documents and Settings\Lab\My Documents\Arduino\libraries\DS1307RTC/DS1307RTC.h:18: error: ‘time_t’ has not been declared
C:\Documents and Settings\Lab\My Documents\Arduino\libraries\DS1307RTC/DS1307RTC.h:19: error: ‘tmElements_t’ has not been declared
C:\Documents and Settings\Lab\My Documents\Arduino\libraries\DS1307RTC/DS1307RTC.h:20: error: ‘tmElements_t’ has not been declared
SetTime:10: error: ‘tmElements_t’ does not name a type
SetTime.ino: In function ‘void setup()’:
SetTime:20: error: ‘tm’ was not declared in this scope
SetTime.ino: In function ‘bool getTime(const char*)’:
SetTime:53: error: ‘tm’ was not declared in this scope
SetTime.ino: In function ‘bool getDate(const char*)’:
SetTime:70: error: ‘tm’ was not declared in this scope
SetTime:72: error: ‘CalendarYrToTm’ was not declared in this scope

What can I do to fix this problem? I’ve looked through some forum posts and seen something about defining things in a separate .h file, but I’m new at this (obviously) and don’t know what I would put in that .h file. Any help you can provide would be wonderful XD

Look at your file tree for the library . Is it in the right place ? Is the example folder in the same folder as the library files ?
Are there duplicate folders with the same name ?
What procedure did you use to install the library ? (exactly?)

Doesn't look like you installed the RTC library correctly.

I went back and deleted all the Time and DS1307RTC files I downloaded, just to be sure there are no duplicates. I re-downloaded them and re-imported them into the library, just to be sure everything is in the right place.

To import them, I did Sketch>Import Library...>Add Library. I then selected the zips from My Downloads. Now both the Time and DS1307RTC libraries appear when I go to Sketch>Import Library... and they are at the bottom under "Contributed." Unfortunately, I'm still getting the same error.

When I go into my Arduino Libraries and then into the Time Library, it contains three folders: Time, TimeAlarms, and DS1307RTC. Should I not download the separate DS1307RTC zip? Could that be my problem? I think the only difference is that the separate DS1307RTC Library has examples.