Go Down

Topic: Getting error with RTCdue lib (Read 2297 times) previous topic - next topic


Apr 15, 2013, 06:27 pm Last Edit: Apr 15, 2013, 06:32 pm by blastboot Reason: 1
Hello, i'm getting this error:

"In file included from TESTE_AJAX_COMPLETO_2.ino:8:
D:\TransferĂȘncias\arduino-1.0.3\libraries\RTCdue/RTCdue.h:49: error: 'PIN_WIRE_SDA' was not declared in this scope
D:\TransferĂȘncias\arduino-1.0.3\libraries\RTCdue/RTCdue.h:49: error: 'PIN_WIRE_SCL' was not declared in this scope

I've run the library examples and i get the same error.
I can't find anything related to this.
Thanks in advance!


My version 1.0.3 of the Arduino IDE did not come with an RTCdue library. Nor did my 1.0.4 version. I'm surprised that yours did.

If it didn't, and you downloaded that library, you put it in the wrong place. And, you didn't tell us where you got it.


My version didn't came with it too  ;)
I downloaded from https://github.com/oskarirauta/RTCdue

I was trying to use this library because i've read that wire.h lib may cause some troubles with sd card, and this rtcdue says that it doesn't need wire library.


Which Arduino are you compiling for?


says it isn't the DUE.

DS1307 library for DUE that doesn't need wire.h. Should work on others as well, just make sure you initialize with sda and scl pins if you cannot get it to work..

The error messages indicate that you did not do this.


I'm compiling for arduino uno. I look at that too but i could't find how to do that.


but i could't find how to do that.

Simplest way is to edit the header file for the class and change those two names for the actual pin numbers (A4 and A5).


Apr 15, 2013, 11:30 pm Last Edit: Apr 15, 2013, 11:36 pm by Sembazuru Reason: 1
From the RTCdue.cpp file on git I see
Code: [Select]

RTC_DS1307::RTC_DS1307(const uint8_t data_pin, const uint8_t sclk_pin) {
 _sda_pin = data_pin;
 _scl_pin = sclk_pin;
 pinMode(_scl_pin, OUTPUT);

That tells me when you initialize the class instead of leaving the parentheses empty (or at the values in the examples), provide two pin numbers for the sda and scl pins. So, on the UNO you would probably want
Code: [Select]

// Init the DS1307
DS1307 rtc(A4, A5);

Edit: clarified my suggestion


I also forgot to mention... For best practices, you should probably should have installed the RTCdue library into your <sketches>\libraries folder instead of in the IDE libraries folder (and your sketches folder shouldn't be in the IDE folder tree). That way when you upgrade your IDE you don't have the accidental possibility of loosing access to the library.


Thank you very much, i've already done what PaulS mention and changed it on header of RTCdue.h file.
Good to know that it can be made that way which is good to change pins whenever we want.

Somethimes i asked myself "I have to change everything everytime that i update arduino IDE?"
of couse after your post i got my answer!
Many thanks to you all, you were very helpful!  ;)


Sembazuru I've tested this:  RTC_DS1307 rtc (A4, A5);  //A4 = SDA --- A5 = SCL
but it keeps giving me the same error:  error: 'PIN_WIRE_SDA' was not declared in this scope
                                                         error: 'PIN_WIRE_SCL' was not declared in this scope


You have a space between "rtc" and "("... I'm not sure if this is allowed. (Not the way I normally write, but that might just be a style issue, not a syntax issue.)


Apr 16, 2013, 12:24 am Last Edit: Apr 16, 2013, 12:26 am by blastboot Reason: 1
Still doesn't work... but as you said it must be working as it says here:

// RTC based on the DS1307 chip connected via I2C and the Wire library
class RTC_DS1307 {
  RTC_DS1307(const uint8_t data_pin = PIN_WIRE_SDA, const uint8_t sclk_pin = PIN_WIRE_SCL);
  void begin(void);
  void adjust(const DateTime& dt);
  uint8_t isrunning(void);
  DateTime now(void);
  uint8_t _scl_pin;
  uint8_t _sda_pin;
  uint8_t _burstArray[8];


doing this:   RTC_DS1307(A4, A5);  //A4 = SDA --- A5 = SCL

It gives another error:   error: 'rtc' was not declared in this scope


but it keeps giving me the same error:  error: 'PIN_WIRE_SDA' was not declared in this scope
                                                         error: 'PIN_WIRE_SCL' was not declared in this scope

Not surprising, as those constants are still (not) defined in the header file.

doing this:   RTC_DS1307(A4, A5);  //A4 = SDA --- A5 = SCL

It gives another error:   error: 'rtc' was not declared in this scope

Enough of the guessing games. Post YOUR code.


Hi I am wondering if you ever find a solution to your problem.
I seems to be having similar issues.
I am using Arduino Due and using DS1307 kit from Adafruit.com
I hook it up per instruction but I use the DS1307 example I got from RTCdue.h github.
When I read the serial monitor, I got

RTC is NOT running!
85.85.2085 85:85:85
since midnight 1/1/1970 = 4162890385s = 48181d
now + 7d + 30s: 26.10.2101 14:26:55

pretty much the date and time are wrong.

I did try this DS1307 kit on an Uno using RTClib.h and it works fine there.

I also use logic level shifter from Sparkfun to convert the 5V I2C signals into 3.3V I2C signals.

Any clue on what is wrong and what I should be looking at?

I also tried changing the code to have
RTC_DS1397 rtc(20,21); and it compiles and loads fine but the time and date are still wrong.

Could the SCL and SDA pin be bad on my board yet the board can still have power and loaded and do serial monitoring?
I measured the voltages on those 2 pins without anything connected to them and read 3.3V. Is this okay?


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131