Pages: [1]   Go Down
Author Topic: RTClib DS1307 with Arduino  (Read 7329 times)
0 Members and 1 Guest are viewing this topic.
London, ON
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Code:
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
Logged

Dialup is the future.

Cookeville, TN
Offline Offline
Newbie
*
Karma: 3
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 - downloaded 268 times.)
Logged

Forum Administrator
Milano, Italy
Offline Offline
Sr. Member
*****
Karma: 23
Posts: 292
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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! smiley
Logged

C.

London, ON
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Code:
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

Logged

Dialup is the future.

Cookeville, TN
Offline Offline
Newbie
*
Karma: 3
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!

Code:
// 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!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

https://github.com/adafruit/RTClib
Logged

Finland
Offline Offline
Newbie
*
Karma: 0
Posts: 45
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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: https://github.com/oskarirauta/RTCdue
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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˜ˆ4ð£ 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?
Logged

Cookeville, TN
Offline Offline
Newbie
*
Karma: 3
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: