DS1307 Clock not Working
Moderators: adafruit_support_bill, adafruit

DS1307 Clock not Working

by techguy777 on Fri Sep 28, 2012 9:34 pm

Hi.
I am having a problem with my ds1307. It was working fine and then all of a sudden it stopped working correctly. I am running the example code for the rtc library
Code: Select all | TOGGLE FULL SIZE
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib

#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 RTC;

void setup () {
    Serial.begin(57600);
    Wire.begin();
    RTC.begin();

  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
}

void loop () {
    DateTime now = RTC.now();
   
    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
   
    Serial.print(" since midnight 1/1/1970 = ");
    Serial.print(now.unixtime());
    Serial.print("s = ");
    Serial.print(now.unixtime() / 86400L);
    Serial.println("d");
   
    // calculate a date which is 7 days and 30 seconds into the future
    DateTime future (now.unixtime() + 7 * 86400L + 30);
   
    Serial.print(" now + 7d + 30s: ");
    Serial.print(future.year(), DEC);
    Serial.print('/');
    Serial.print(future.month(), DEC);
    Serial.print('/');
    Serial.print(future.day(), DEC);
    Serial.print(' ');
    Serial.print(future.hour(), DEC);
    Serial.print(':');
    Serial.print(future.minute(), DEC);
    Serial.print(':');
    Serial.print(future.second(), DEC);
    Serial.println();
   
    Serial.println();
    delay(3000);
}
When I'm running the problem I get the following response from the Serial Connection.
2165/165/165 165:165:85
since midnight 1/1/1970 = 1402703185s = 16234d
now + 7d + 30s: 2014/6/20 23:46:55

I have checked all the wiring and soldering connections and they all look good.
Thanks in advance!
Last edited by adafruit_support_rick on Fri Sep 28, 2012 9:46 pm, edited 2 times in total.
Reason: Locked due to double post. see here: http://forums.adafruit.com/viewtopic.php?f=41&t=33277
techguy777
 
Posts: 6
Joined: Fri Sep 28, 2012 9:24 pm



cron