Pages: 1 ... 4 5 [6] 7 8   Go Down
Author Topic: Library for DS1307 Real Time Clock  (Read 29474 times)
0 Members and 2 Guests are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 43
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


No you can remove byte data[56], it's not used.
Logged

Milano, Italy
Offline Offline
Faraday Member
**
Karma: 10
Posts: 3085
Sideralis Arduino!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What's the meaning of this part of the code?

Code:
for(int i=0; i<56; i++)
  {
  RTC.set_sram_byte(i+64,i);
  }

And... Is there someone that can give me an example on how to program an alarm?

Last thing.. for setting up the base time, we have to set the rtc, but there is a delay between the time that I write and the time of setting, as the arduino needs a couple of seconds for compiling the code... someone knows a more professional method to set up the rtc, instead of guessing the time needed to compile?

Thanks, Fede
Logged

Federico - Sideralis
Arduino &C: http://www.sideralis.org
Foto: http://blackman.amicofigo.com

0
Offline Offline
Faraday Member
**
Karma: 7
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
for setting up the base time, we have to set the rtc, but there is a delay between the time that I write and the time of setting, as the arduino needs a couple of seconds for compiling the code... someone knows a more professional method to set up the rtc, instead of guessing the time needed to compile?
Put a future time in the code, and have the sketch a) print the time, and b) use Serial.available() to wait for a character transmission to actually initiate the clock set.  That's how I did it, anyway.

-j

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 43
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I had a pde which listened to the serial input and looked for the following sequences, and set the clock accordingly.
Snn
Mnn
Hnn
Dddmmyy

I can;t find my pde smiley-sad
Not hard to write though.
« Last Edit: June 04, 2009, 06:43:40 am by mattt » Logged

Milano, Italy
Offline Offline
Faraday Member
**
Karma: 10
Posts: 3085
Sideralis Arduino!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you find it, it will be appreciated smiley-wink
Oh, and thanks for the library!

Any hint about the alarm? (two or three post above)
Logged

Federico - Sideralis
Arduino &C: http://www.sideralis.org
Foto: http://blackman.amicofigo.com

0
Offline Offline
Newbie
*
Karma: 0
Posts: 43
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


For an alarm you'd probably be better off with a DS1337, that has two alarms.  

xSmurf wrote a lib for it.
Read from here : http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1191209057/6#6

With the DS1307, you'll could periodically read the RTC data and compare it against a predetermined time.



Logged

Milano, Italy
Offline Offline
Faraday Member
**
Karma: 10
Posts: 3085
Sideralis Arduino!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you! I don't really need an alarm now, but I wanted to understand this chip as better as possible. Great, great work mattt, and everyone who contributed!
Logged

Federico - Sideralis
Arduino &C: http://www.sideralis.org
Foto: http://blackman.amicofigo.com

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

Mattt

Have you had a chance to update this library to include the 12 hour, AM/PM mode?

Thanks
Logged

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

Thanks for you work Mattt and others!

Downloaded the code from Google code and had it up and running in no time.

Much appreciated!
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I observe a strange behaviour on some of the SRAM registers on my DS1307 ...

Like in the example, I am resetting the SRAM with

for(int i=0; i<56; i++)
  {
    RTC.set_sram_byte(65,i);
  }


and then reading it with
 RTC.get_sram_data(data);
  for(int i=0; i<56; i++)
  {
    Serial.print(data+0);
    Serial.print(" ");
  }


the result is strange:

65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 18 65 4 65 8 65 3 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65

i.e. I seem to have registers 26, 28, 30, 32 which apparently contain other values than what I wrote into them? Anybody got an idea why that might be?
« Last Edit: August 13, 2009, 04:32:24 pm by dg1sek » Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 423
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I would like also to develop a scientific devide consisting on a arduino duemilenove, two (for the moment) temperature sensors (DS18N20), a RTC (DS1307), and a microSD component. My idea is to measure temperature from each sensor one per hour, and save in a txt file at the microSD file, together with date, time and the temperature from each sensor.

I saw some of you are involve in similar devides. Since i am completely new in arduino, could you give me the detailed steps to develop it? You seems to have so much experience and could made me easy to go ahead with this project.

Details about what i have:
Arduino duemilenove: http://www.bricogeek.com/shop/10-arduino-duemilanove-usb.html
Temperature sensors DS18B20: http://www.bricogeek.com/shop/41-sensor-de-temperatura-ds18b20-one-wire.html
RTC DS1307: http://www.bricogeek.com/shop/56-placa-reloj-rtc-ds1307.html
MicroSD: http://www.libelium.com/tienda/catalog/product_info.php?cPath=21&products_id=66

Thanks!
« Last Edit: September 30, 2009, 02:10:10 pm by madepablo » Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 115
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

New DS1337 owner here, should I jump in with the code posted at the beginning of the thread specifically for the DS1337 or go with the DS1307 library listed later on Google source?

I picked up a nice couple of CronoDots with the headers soldered on the wrong side for cheap at macetech.com. Look for the ChronoDoh!
Logged

Boston, MA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1024
wiblocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are just starting out on the DS1337 you may want to checkout my library at
http://tinyurl.com/pg334s. I have implemented most functions of the chip.
The library works with the Arduino and Sanguino.

I have a couple of Arduino examples on the site. One outputs a localtime string. The
other demos the interrupts. I will be posting the Sanguino examples (with pics of my
new board) in the next few days.

(* jcl *)

------------------------------------
www: http://www.wiblocks.com
twitter: http://twitter.com/wiblocks
blog: http://luciani.org
Logged


0
Offline Offline
Full Member
***
Karma: 0
Posts: 115
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ha ha! It lives!

Soldered the backup battery on, wired it up very carefully, and tried the most basic sketch from the macetech.com documentation that doesn't use any library.

It's ticking and spitting out the wrong time! (I haven't set it yet)
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 115
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok, tried jluciani's library first. Nothing comes back on the serial port at all. Here is what I tried:

Code:
#include <TWI.h>
#include <RTC.h>

#define int_enable   PCICR  |= (1 << PCIE1)
#define int_disable  PCICR  &= ~(1 << PCIE1)

RTC rtc;

void setup()
{
  Serial.begin(9600);
  // setup the TWI

  TWBR = TWI_TWBR;                         // Set bit rate register (Baudrate). Defined in TWI.h  
  TWDR = 0xFF;                             // Default content = SDA released.

  TWCR = (1<<TWEN)|                        // Enable TWI-interface and release TWI pins.
         (0<<TWIE)|(0<<TWINT)|             // Disable Interupt.
         (0<<TWEA)|(0<<TWSTA)|(0<<TWSTO)|  // No Signal requests.
         (0<<TWWC);

  int_enable;

  // initialize the date
  // rtc.set_date(2009, 9, 30);

  // intialize the clock
  // rtc.set_time(18, 37, 0);
}


void loop() {
  char timestr[22];
  while(1) {
    rtc.read_regs();
    rtc.localtime(timestr);
    Serial.print(timestr);
    Serial.print("\r");
    delay(1000);
  }
}
Logged

Pages: 1 ... 4 5 [6] 7 8   Go Up
Jump to: