RTClib DS1307 with Arduino

Hello,

I got the RTClib from ladyada but running it with my code, I am getting the following error. Are people getting this library to work with them?

motortestdue:56: error: expected ')' before '*' token
motortestdue:56: error: expected ')' before '*' token
motortestdue.ino: In function 'void dateTime(uint16_t*, uint16_t*)':
motortestdue:60: error: request for member 'now' in '1074666080u', which is of non-class type 'Rtc*'
motortestdue.ino: In function 'void setup()':
motortestdue:119: error: request for member 'begin' in '1074666080u', which is of non-class type 'Rtc*'
motortestdue:123: error: request for member 'now' in '1074666080u', which is of non-class type 'Rtc*'
motortestdue.ino: In function 'void loop()':
motortestdue:234: error: request for member 'now' in '1074666080u', which is of non-class type 'Rtc*'

Or, does anyone else have a good RTC DS library?

Dan

Hey, I dug into the Adafruit library for the DS1307 and I have updated it to be compatible with the Arduino Due. I have attached a zip with the new Library in it. Be aware that the examples will apparently not work until you save them in the new ino file format. So open the example you want to run, resave it under a different name, and then it should compile and run. Also, are you planning on using the Adafruit breakout board for the DS1307?

Cheers!

RTClib.zip (5.54 KB)

SomeRandomGuy:
Hey, I dug into the Adafruit library for the DS1307 and I have updated it to be compatible with the Arduino Due.

Hope that you have tried to push it back to Adafruit the updated version! :slight_smile:

Hello,

With the new library, I am running "ds1307" example in a new .pde file and I am getting the same error as the previous library.

test:6: error: expected ')' before '*' token
test:6: error: expected ')' before '*' token
test.ino: In function 'void setup()':
test:11: error: request for member 'begin' in '1074666080u', which is of non-class type 'Rtc*'
test:13: error: request for member 'isrunning' in '1074666080u', which is of non-class type 'Rtc*'
test:16: error: request for member 'adjust' in '1074666080u', which is of non-class type 'Rtc*'
test.ino: In function 'void loop()':
test:21: error: request for member 'now' in '1074666080u', which is of non-class type 'Rtc*'

This seems to be bug, would you know why this is the case? Many poeple on the forums are getting this error.

Daniel

Ahh, I knew I was missing something. You will also need to edit the example sketch. The RTC object that is used in the example needs to be de-capitalized everywhere it is used. This is a reserved feature/bug in the complier where it does not like variables in all caps. Change that throughout the sketch to "rtc" and it should complile right up!

// 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 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);
}

Let me know if that works for ya!

I was able to use the DS1307 with the RTClib from jeelabs, the examples work no problem once you get the DS1307 hooked up correctly - I don't have the breakout board from Adafruit, I just have the chip and a 32 mhz oscillator and a breadboard. Works like a champ.

Here is the link to the RTClib I used on the Due.

I've combined Henning Karlsen's library with RTClib and fixed day of week calculation as well. Library does not require wire.h and works just like RTClib except, you can set alternative sda and scl pins if you like.
Library is available here: GitHub - oskarirauta/RTCdue: DS1307 library for DUE that doesn't need wire.h

When I run the example DS1307, my serial window shows this:

£ OpÂd?z'B÷BKQ ]"OÿÂd?z'B÷BKS"]"_ÿÂd??+ÆWÆã ] Oÿ£ MÞQ>¡:I??4eð£ Yí"ð?V« \BæÀ?£ Yí??VBECµ ûJËâDéóZÕ(
«ãQ Y OÿÂd?;ÄB÷BKS]Mÿ?4=Q'BcbK2ñ¡þâDÙ3+?fWÒã Y [ÿÂdAûN#

á$ïÈ¡
©äÂdA;N#
ä$ïÈ¡
©ä¢D¡özÑ<á?4Y¢KùÂdáóZÅ(
á4ï?¡

ä

Any ideas what might be going on?

The example is using a very high serial baud rate (115200). You probably don't have your serial monitor set to that high of a baud rate. (its a dropdown menu in the bottom right hand corner.

Hope that helps!
SRG