Can't compile RTC breakout example [SOLVED]

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
DanPolka
 
Posts: 108
Joined: Tue Feb 18, 2014 5:31 am

Can't compile RTC breakout example [SOLVED]

Post by DanPolka »

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 2:05 am, edited 2 times in total.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Can't compile RTC breakout example

Post by adafruit_support_bill »

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.

DanPolka
 
Posts: 108
Joined: Tue Feb 18, 2014 5:31 am

Re: Can't compile RTC breakout example

Post by DanPolka »

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?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Can't compile RTC breakout example

Post by adafruit_support_bill »

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.

DanPolka
 
Posts: 108
Joined: Tue Feb 18, 2014 5:31 am

Re: Can't compile RTC breakout example

Post by DanPolka »

Thanks!! Very fast reply, very helpful!!
It compiles fine now!

DanPolka
 
Posts: 108
Joined: Tue Feb 18, 2014 5:31 am

Re: Can't compile RTC breakout example

Post by DanPolka »

Is there some way to indicate on the posting that this problem has been solved??

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Can't compile RTC breakout example

Post by adafruit_support_bill »

You should be able to just edit the first post (see edit button on upper right of message) and change the title.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”