DS1307 time set error

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

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?

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

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

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

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 - Arduino Playground - DS1307OfTheLogshieldByMeansOfNTP

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