user6251: I have a RTC module DS1307 (MR005-001.2) on my Arduino Uno.
I use the Wire.h / Time.h / DS1307RTC.h libraries.
The date and time returned is completely wrong ("17:18:9 2 4 2036") ... What do I do wrong ??
Thanks !
Here is my partial code for setup() :
    setSyncProvider(RTC.get);
  if(timeStatus()!= timeSet) 
     Serial.println("Unable to sync with the RTC");
  else
     Serial.println("RTC has set the system time");

This writes "RTC has set the system time", so I guess something is happening right...
Here is my partial code for loop() :
    Serial.print(hour());
  Serial.print(":");
  Serial.print(minute());
  Serial.print(":");
  Serial.print(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year()); 
  Serial.println();

Just as in the example ... and the date/time returned is "17:18:9 2 4 2036"

user6628: You setup interpretation should be more like:
 setSyncProvider(RTC.get);
 if(timeStatus()!= timeSet) 
   Serial.println("RTC has never been set");
 else
    Serial.println("RTC has a time");

To conditionally sync the clock to the compilation time if the clock is not running:
if (! RTC.isrunning()) {
   Serial.println("RTC is NOT running!");
   // following line sets the RTC to the date & time this sketch was compiled
   // uncomment it & upload to set the time, date and start run the RTC!
   RTC.adjust(DateTime(__DATE__, __TIME__));
}
// following line unconditionally resets the RTC to the date & time this sketch was compiled
// uncomment it & upload to set the time, date and start run the RTC!
// RTC.adjust(DateTime(__DATE__, __TIME__));

To unconditionally sync it to the compilation time, uncomment the last line and reload for one cycle, then re-comment it and reload to let the clock run itself.

6251: <p>I have a RTC module DS1307 (MR005-001.2) on my Arduino Uno.
I use the Wire.h / Time.h / DS1307RTC.h libraries.</p>

<p>The date and time returned is completely wrong ("17:18:9 2 4 2036") ... What do I do wrong ??</p>

<p>Thanks !</p>

<p>Here is my partial code for setup() :</p>

<pre><code>    setSyncProvider(RTC.get);
  if(timeStatus()!= timeSet) 
     Serial.println("Unable to sync with the RTC");
  else
     Serial.println("RTC has set the system time");
</code></pre>

<p>This writes "RTC has set the system time", so I guess something is happening right...</p>

<p>Here is my partial code for loop() :</p>

<pre><code>    Serial.print(hour());
  Serial.print(":");
  Serial.print(minute());
  Serial.print(":");
  Serial.print(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year()); 
  Serial.println();
</code></pre>

<p>Just as in the example ... and the date/time returned is "17:18:9 2 4 2036"</p>
 6628: <p>You setup interpretation should be more like:</p>

<pre><code> setSyncProvider(RTC.get);
 if(timeStatus()!= timeSet) 
   Serial.println("RTC has never been set");
 else
    Serial.println("RTC has a time");
</code></pre>

<p>To conditionally sync the clock to the compilation time if the clock is not running:</p>

<pre><code>if (! RTC.isrunning()) {
   Serial.println("RTC is NOT running!");
   // following line sets the RTC to the date &amp; time this sketch was compiled
   // uncomment it &amp; upload to set the time, date and start run the RTC!
   RTC.adjust(DateTime(__DATE__, __TIME__));
}
// following line unconditionally resets the RTC to the date &amp; time this sketch was compiled
// uncomment it &amp; upload to set the time, date and start run the RTC!
// RTC.adjust(DateTime(__DATE__, __TIME__));
</code></pre>

<p>To unconditionally sync it to the compilation time, uncomment the last line and reload for one cycle, then re-comment it and reload to let the clock run itself.</p>
