Pages: [1]   Go Down
Author Topic: Real Time Clock DS1307  (Read 4956 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 2
Posts: 226
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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 :-(
plz help

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

Code:
// 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 :-(

please help, im so frustrated
« Last Edit: July 12, 2012, 06:06:14 pm by lax123 » Logged

0
Offline Offline
Shannon Member
****
Karma: 220
Posts: 12700
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Full Member
***
Karma: 2
Posts: 226
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

« Last Edit: July 12, 2012, 06:22:03 pm by lax123 » Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 226
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Shannon Member
****
Karma: 220
Posts: 12700
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Full Member
***
Karma: 2
Posts: 226
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well i never said i used it without a battery...
Quote
"i didnt connect the backup battery, it was connected out of the box"

Quote

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:
Quote
purpose is to keep time during power-off
« Last Edit: July 13, 2012, 10:09:54 am by lax123 » Logged

0
Offline Offline
Shannon Member
****
Karma: 220
Posts: 12700
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1287
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Pages: [1]   Go Up
Jump to: