Can't compile RTC breakout example [SOLVED]

by DanPolka on Tue Feb 18, 2014 4:40 am

I can't get the example sketch from the RTClib for Adafruit DS1307 Real Time Clock breakout board kit to compile.

I'm on a Windows Vista machine, Arduino UNO Rev3, IDE 1.0, and I haven't had any such problem compiling OTHER sketches, so I presume my general library placement is correct.

The example in question is from a RTClib I got from here:
https://github.com/adafruit/RTClib
following instructions from here:
http://learn.adafruit.com/ds1307-real-t ... no-library
which I got to from here:
http://www.adafruit.com/products/264

I suspect either I got a wrong library, or it's somehow in the wrong place, or it's something else related to the library?

My Arduino library & the RTC lib is located thus:
C:\Users\Dan (Admin)\Documents\Arduino\libraries\RTClib\examples

And I'm trying to compile the ds1307 example sketch.

Here's the code from the example:

Code: Select all
// 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);
#ifdef AVR
  Wire.begin();
#else
  Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
  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 midnight 1/1/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);
}

Here's the error message:

C:\Users\Dan (Admin)\Documents\Arduino\libraries\RTClib\RTClib.cpp: In member function 'uint8_t RTC_DS1307::isrunning()':
C:\Users\Dan (Admin)\Documents\Arduino\libraries\RTClib\RTClib.cpp:148: error: call of overloaded 'write(int)' is ambiguous
C:\Program Files\Arduino\arduino-1.0\libraries\Wire/Wire.h:55: note: candidates are: virtual size_t TwoWire::write(uint8_t)
C:\Program Files\Arduino\arduino-1.0\hardware\arduino\cores\arduino/Print.h:49: note: size_t Print::write(const char*)
C:\Users\Dan (Admin)\Documents\Arduino\libraries\RTClib\RTClib.cpp: In static member function 'static void RTC_DS1307::adjust(const DateTime&)':
C:\Users\Dan (Admin)\Documents\Arduino\libraries\RTClib\RTClib.cpp:158: error: call of overloaded 'write(int)' is ambiguous
C:\Program Files\Arduino\arduino-1.0\libraries\Wire/Wire.h:55: note: candidates are: virtual size_t TwoWire::write(uint8_t)
C:\Program Files\Arduino\arduino-1.0\hardware\arduino\cores\arduino/Print.h:49: note: size_t Print::write(const char*)
C:\Users\Dan (Admin)\Documents\Arduino\libraries\RTClib\RTClib.cpp:166: error: call of overloaded 'write(int)' is ambiguous
C:\Program Files\Arduino\arduino-1.0\libraries\Wire/Wire.h:55: note: candidates are: virtual size_t TwoWire::write(uint8_t)
C:\Program Files\Arduino\arduino-1.0\hardware\arduino\cores\arduino/Print.h:49: note: size_t Print::write(const char*)
C:\Users\Dan (Admin)\Documents\Arduino\libraries\RTClib\RTClib.cpp: In static member function 'static DateTime RTC_DS1307::now()':
C:\Users\Dan (Admin)\Documents\Arduino\libraries\RTClib\RTClib.cpp:172: error: call of overloaded 'write(int)' is ambiguous
C:\Program Files\Arduino\arduino-1.0\libraries\Wire/Wire.h:55: note: candidates are: virtual size_t TwoWire::write(uint8_t)
C:\Program Files\Arduino\arduino-1.0\hardware\arduino\cores\arduino/Print.h:49: note: size_t Print::write(const char*)
Last edited by DanPolka on Thu Feb 20, 2014 1:05 am, edited 2 times in total.
DanPolka
 
Posts: 108
Joined: Tue Feb 18, 2014 4:31 am

Re: Can't compile RTC breakout example

by adafruit_support_bill on Tue Feb 18, 2014 7:37 am

This is a known issue in V1.0 of the IDE. http://www.adafruit.com/forums/viewtopi ... 39#p209509
Try a more recent version of the IDE. Avoid the 1.5.x beta version for now, 1.0.4 and 1.0.5 are both quite stable.
User avatar
adafruit_support_bill
 
Posts: 25412
Joined: Sat Feb 07, 2009 9:11 am

Re: Can't compile RTC breakout example

by DanPolka on Tue Feb 18, 2014 7:49 am

Thanks!! Is there any specific way to apply the download of the newer IDE so as to retain my current sketches with the new IDE?
DanPolka
 
Posts: 108
Joined: Tue Feb 18, 2014 4:31 am

Re: Can't compile RTC breakout example

by adafruit_support_bill on Tue Feb 18, 2014 8:19 am

It looks like you have 1.0 installed here:
Code: Select all
C:\Program Files\Arduino\arduino-1.0

And your sketches and library installs are in:
Code: Select all
C:\Users\Dan (Admin)\Documents\Arduino

and
Code: Select all
C:\Users\Dan (Admin)\Documents\Arduino\libraries\


Just install 1.0.5 here:
Code: Select all
C:\Program Files\Arduino\arduino-1.0.5

And it will be able to find all your existing libraries and sketches.
User avatar
adafruit_support_bill
 
Posts: 25412
Joined: Sat Feb 07, 2009 9:11 am

Re: Can't compile RTC breakout example

by DanPolka on Tue Feb 18, 2014 8:31 am

Thanks!! Very fast reply, very helpful!!
It compiles fine now!
DanPolka
 
Posts: 108
Joined: Tue Feb 18, 2014 4:31 am

Re: Can't compile RTC breakout example

by DanPolka on Wed Feb 19, 2014 5:43 am

Is there some way to indicate on the posting that this problem has been solved??
DanPolka
 
Posts: 108
Joined: Tue Feb 18, 2014 4:31 am

Re: Can't compile RTC breakout example

by adafruit_support_bill on Wed Feb 19, 2014 7:05 am

You should be able to just edit the first post (see edit button on upper right of message) and change the title.
User avatar
adafruit_support_bill
 
Posts: 25412
Joined: Sat Feb 07, 2009 9:11 am