Go Down

Topic: DS1307 time set error (Read 3115 times) previous topic - next topic

Paulius

Jan 10, 2011, 10:27 pm Last Edit: Jan 10, 2011, 10:28 pm by Paulakiux Reason: 1
Hi!

RTC worked until I have installed windows 7. Before I was using XP and RTC was setting by uploading program to arduino. I am using RTC library and setting line is:

if (! RTC.isrunning()) {
   RTC.adjust(DateTime(__DATE__, __TIME__));
 }

Now, after uploading program to arduino, RTC shows not real time, like now is 23:25, it shows 6:40. What should I do?

Thanks for help, sorry for my English  :)

PaulS

Code: [Select]
if (! RTC.isrunning()) {
  RTC.adjust(DateTime(__DATE__, __TIME__));
}

This code will adjust (not set) the time/date based on when the sketch was compiled. Is that what you really want to do?

Paulius

Yes, it has been working until I have uploaded program with new OS. If this line is incorrect, what should I write?

Paulius

I think, I will write win XP to my PC... :)

Paulius

Found the problem :) Before I program arduino, I need to get off electricity of RTC and then time sets just 1 time. Smth mysterious  :-?

robtillaart

If the clock on your PC is wrong the code in the sketch won't work either.

Maximum accuracy can be obtained by using timeservers, however you need an ethernetshield. See - http://www.arduino.cc/playground/Main/DS1307OfTheLogshieldByMeansOfNTP
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

PaulS

It also helps if you call RTC.set(), rather than RTC.adjust().

Go Up