Real Time Clock DS1307

Hi,

i bought this real time clock module:
http://www.ebay.de/itm/261043197718?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649

but i have problems to get it running, first of all like 90% of all libraries were pre 1.0 after changing the commands i still could not compile..
then i found another library with an example that did compile but its still not working.

Could anyone please tell me where i could find the latest libraries and instructions?? :-/

and i would love just a simple example that shows me the current time and date of the clock.
examples that did compile just show the same date and time over and over again, maybe thats intendet or not i dont know :frowning:

As only repeating output from serial i get from chronodot lib with example:
2011/04/04 22:07:00
and temp values.
Time and other values r not changing at all :frowning:
plz help

this is the code from a compiling example with lib chronodot:

// Date, time and temperature functions using 
// a Chronodot RTC connected via I2C and Wire lib

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

Chronodot RTC;

void setup () {
    Serial.begin(9600);
    Serial.println("Initializing Chronodot.");

    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('/');
    if(now.month() < 10) Serial.print("0");
    Serial.print(now.month(), DEC);
    Serial.print('/');
    if(now.day() < 10) Serial.print("0");
    Serial.print(now.day(), DEC);
    Serial.print(' ');
    if(now.hour() < 10) Serial.print("0");
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    if(now.minute() < 10) Serial.print("0");
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    if(now.second() < 10) Serial.print("0");
    Serial.print(now.second(), DEC);
    Serial.println();

    Serial.print(now.tempC(), 1);
    Serial.println(" degrees Celcius");
    Serial.print(now.tempF(), DEC);
    Serial.println(" degrees Farenheit");
    
    Serial.println();
    delay(3000);
}

On DS1307new_v1.23 library and example i get a similar output like this:
DS1307 Testsketch
Format is "hh:mm:ss dd-mm-yyyy DDD"
MEZ=0, MESZ=1 : 1

22:07:00 08-04-2011 FRI seconds since 1.1.2000:355615620 MEZ=0, MESZ=1 : 1 - Address in NV-RAM is: 0 - Clock was set!
22:07:00 08-04-2011 FRI seconds since 1.1.2000:355615620 MEZ=0, MESZ=1 : 1 - Address in NV-RAM is: 1 - Clock was set!
22:07:00 08-04-2011 FRI seconds since 1.1.2000:355615620 MEZ=0, MESZ=1 : 1 - Address in NV-RAM is: 2 - Clock was set!
22:07:00 08-04-2011 FRI seconds since 1.1.2000:355615620 MEZ=0, MESZ=1 : 1 - Address in NV-RAM is: 3 - Clock was set!

nothing is changing....
and monitor example just shows:
DS1307 Monitor (enable LF/CR, type 'h' for help)

on h +enter nothing happens at all :frowning:

please help, im so frustrated

After connecting the backup battery the chip may power up with the clock disabled - one of the bits in one of the registers has to be set to enable the clock - so long as there is battery backup it will then keep running until you clear the bit again.

Thx for the response, but i didnt connect the backup battery, it was connected out of the box. so this must be fixed?
how would i exactly have to enable the clock again, sorry im newb :frowning:

oh noes, i disconncted the battery and put it in again, plugged into arduino, and now date and time is only gibberish
DS1307 Testsketch
Format is "hh:mm:ss dd-mm-yyyy DDD"
MEZ=0, MESZ=1 : 0

165:165:85 165-165-2165 MON seconds since 1.1.2000:1076433489 MEZ=0, MESZ=1 : 0 - Address in NV-RAM is: 0 - Clock was set!
165:165:85 165-165-2165 MON seconds since 1.1.2000:1076433489 MEZ=0, MESZ=1 : 0 - Address in NV-RAM is: 1 - Clock was set!
165:165:85 165-165-2165 MON seconds since 1.1.2000:1076433489 MEZ=0, MESZ=1 : 0 - Address in NV-RAM is: 2 - Clock was set!

does the monitor programm only outputs:
and why DS1307 Monitor (enable LF/CR, type 'h' for help)

and nothing happens, also h+enter nothing happens

tried some other things and suddenly it works just fine using these sketches:

http://bildr.org/2011/03/ds1307-arduino/

maybe because its not using a ds1307 lib?

The DS1307 requires the battery to be connected to oscillate I think. Certainly its pretty useless without battery backup as its purpose is to keep time during power-off.

well i never said i used it without a battery...

"i didnt connect the backup battery, it was connected out of the box"

The DS1307 requires the battery to be connected to oscillate I think

from i what i found thats not the case, its just needed for:

purpose is to keep time during power-off

I dont remember the datasheet saying anything about guaranteed behaviour with no battery.

And I read "I didn't connect the battery" as "It wasn't connected", sorry.

Yes you need to program the device after removing/replacing the battery as all its state is all static RAM which needs power to work. The RAM starts up at random after backup power loss. I don't remember there being anyway to test for either no battery or that the battery has been replaced.

I had the same issue, same RTC, arduino UNO, different code. (that's how I found this topic)

I used A5 for SDA and A4 for SCL - I commented to myself as a reminder in the begining of the sketch
I tryed to code and interrupt - for temperature (one button display change to show temp)

During I hassel around the code, I pulled out RTC to not "interfere". When I connected back to my original program I had the same. 165 on hours etc.
I noticed this is the same without RTC.

I swapped the wires on A5,A4 now it is working again properly clock, date set.

hope it helps you, Krstf04

I have a library that I wrote for myself that works ok. The example code allows you to fiddle and view stuff thru the serial interface. If interested, you can find it at

http://code.google.com/p/arduino-code-repository