Go Down

Topic: DS1307 with my Arduino Due (Read 908 times) previous topic - next topic

Seb823

Mar 22, 2013, 03:37 pm Last Edit: Mar 22, 2013, 03:48 pm by Seb823 Reason: 1
Hello,

i want to connect the DS1307 with my Arduino Due. http://arduino.alhin.de/index.php?n=45

But everytime when i verify i got an error message

Quote

sketch_mar22a:10: error: expected ')' before '*' token
sketch_mar22a:10: error: expected ')' before '*' token
sketch_mar22a.ino: In function 'void setup()':
sketch_mar22a:16: error: request for member 'begin' in '1074666080u', which is of non-class type 'Rtc*'
sketch_mar22a:17: error: request for member 'isrunning' in '1074666080u', which is of non-class type 'Rtc*'
sketch_mar22a:20: error: request for member 'adjust' in '1074666080u', which is of non-class type 'Rtc*'
sketch_mar22a.ino: In function 'void loop()':
sketch_mar22a:25: error: request for member 'now' in '1074666080u', which is of non-class type 'Rtc*'v


Quote

This Erros:
sketch_mar22a:10: error: expected ')' before '*' token
sketch_mar22a:10: error: expected ')' before '*' token

Means this line:
RTC_DS1307 RTC;


I used the Libary from https://nodeload.github.com/adafruit/RTClib/zip/master

Quote

//Bibliotheken
#include <Wire.h>
#include "RTClib.h"

//Real Time Clock
RTC_DS1307 RTC;

//Main Setup
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 () {
 // Uhrzeit auslesen und in "now" speichern:
 DateTime now = RTC.now();
 // Datum und Uhrzeit auf dem serial monitor ausgeben:
 Serial.print(now.day(), DEC);
 Serial.print('.');   Serial.print(now.month(), DEC);
 Serial.print('.');
 Serial.print(now.year(), DEC);
 Serial.print(' ');
 Serial.print(now.hour(), DEC);
 Serial.print(':');
 Serial.print(now.minute(), DEC);
 Serial.print(':');
 Serial.print(now.second(), DEC);
 Serial.println();
 delay(3000);
}



I hope you can help me.

greetz
Sebastian

afremont

Try adding this:
#include "Arduino.h"
Experience, it's what you get when you were expecting something else.

Seb823

#2
Mar 22, 2013, 03:53 pm Last Edit: Mar 22, 2013, 04:00 pm by Seb823 Reason: 1
Same error at this change

Quote

//Bibliotheken
#include <Wire.h>
#include "RTClib.h"
#include "Arduino.h"


Why these are the only one how is blue and in " " ... I have included all Librarys and these are the only one.

afremont

I'm not much of a C++ person, is this right to have const the way it is used:
Code: [Select]

class DateTime {
public:
    DateTime (uint32_t t =0);
    DateTime (uint16_t year, uint8_t month, uint8_t day,
                uint8_t hour =0, uint8_t min =0, uint8_t sec =0);
    DateTime (const char* date, const char* time);
    uint16_t year() const       { return 2000 + yOff; }                   // <----   IS THIS RIGHT WAY TO USE const
    uint8_t month() const       { return m; }
    uint8_t day() const         { return d; }
    uint8_t hour() const        { return hh; }
    uint8_t minute() const      { return mm; }
    uint8_t second() const      { return ss; }
    uint8_t dayOfWeek() const;

    // 32-bit times as seconds since 1/1/2000
    long secondstime() const;   
    // 32-bit times as seconds since 1/1/1970
    uint32_t unixtime(void) const;

protected:
    uint8_t yOff, m, d, hh, mm, ss;
};
Experience, it's what you get when you were expecting something else.

Seb823

Thanks four youre help but this has nothig to do with my sketch problem at his time, or i diddnt see it? I have found these Sketch in different ways, but the Problem with the "RTC" command is the same... :(

afremont


Thanks four youre help but this has nothig to do with my sketch problem at his time, or i diddnt see it? I have found these Sketch in different ways, but the Problem with the "RTC" command is the same... :(


I posted the class definition from the RTClib.h header file.  The RTC_DS1307 class references that DateTime class and I'm wondering if that's what causes the error.  That "const" in the class definition looks suspicious to me, but I'm not a C++ expert.
Experience, it's what you get when you were expecting something else.

Seb823

Ok, now i get it. Thank you.

I hope anyone else have experience with it.

Seb823

I tried somthing.

When i chance my "Board" in this Arduino Software from "Arduino Due" to "Arduino Uno" it works directly... can anyone explain it to me? Or its a bug?

afremont


I tried somthing.

When i chance my "Board" in this Arduino Software from "Arduino Due" to "Arduino Uno" it works directly... can anyone explain it to me? Or its a bug?


When you say "it works", I guess you mean that it compiles.  I don't see how it would be possible to upload the generated code and have it run since the Due is a 32-bit ARM based processor and the UNO is an 8-bit AVR processor.  The generated object and subsequent machine code could not possibly execute.

If it compiles now, then it's a bug in the header files.  The Due is fairly different and requires some effort for the libraries to support it.
Experience, it's what you get when you were expecting something else.

PaulS

@afremont:
Quote
Try adding this:
#include "Arduino.h"

Incomplete advice is worse than no advice. You need to define WHERE you think this needs to be done.

Clearly, it doesn't. In the sketch, the IDE adds an include statement to include Arduino.h during the conversion to a cpp file.

The library needs to have added this, already.

Quote
When i chance my "Board" in this Arduino Software from "Arduino Due" to "Arduino Uno" it works directly... can anyone explain it to me? Or its a bug?

What version of the IDE are you using? Only 1.5.1+ can be used with the DUE.

afremont

Ok so the Arduino.h didn't help, but it didn't hurt anything either.  What about my questions about the use of "const" in the class definitions?  Is that the correct syntax?
Experience, it's what you get when you were expecting something else.

PaulS

Quote
What about my questions about the use of "const" in the class definitions?  Is that the correct syntax?

Yes, it's fine. Typically, you put the const at the front, but it doesn't really matter.

Go Up