Pages: [1]   Go Down
Author Topic: DS1307 time set error  (Read 2688 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley
« Last Edit: January 10, 2011, 04:28:36 pm by Paulakiux » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think, I will write win XP to my PC... smiley
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13477
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Rob Tillaart

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: