Go Down

Topic: Library for DS1307 Real Time Clock (Read 42474 times) previous topic - next topic

mattt


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

Federico

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

Code: [Select]

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
Federico - Sideralis
Arduino &C: http://www.sideralis.org
Foto: http://blackman.amicofigo.com

kg4wsv

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


mattt

#78
Jun 04, 2009, 01:43 pm Last Edit: Jun 04, 2009, 01:43 pm by mattt Reason: 1
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 :(
Not hard to write though.

Federico

If you find it, it will be appreciated ;)
Oh, and thanks for the library!

Any hint about the alarm? (two or three post above)
Federico - Sideralis
Arduino &C: http://www.sideralis.org
Foto: http://blackman.amicofigo.com

mattt


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.




Federico

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!
Federico - Sideralis
Arduino &C: http://www.sideralis.org
Foto: http://blackman.amicofigo.com

strifilo

Mattt

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

Thanks

apolo

Thanks for you work Mattt and others!

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

Much appreciated!

Siegfried Loeffler

#84
Aug 13, 2009, 11:30 pm Last Edit: Aug 13, 2009, 11:32 pm by dg1sek Reason: 1
I observe a strange behaviour on some of the SRAM registers on my DS1307 ...

Like in the example, I am resetting the SRAM with

[font=Courier]for(int i=0; i<56; i++)
 {
   RTC.set_sram_byte(65,i);
 }[/font]

[font=Microsoft Sans Serif]and then reading it with[/font]
[font=Courier]  RTC.get_sram_data(data);
 for(int i=0; i<56; i++)
 {
   Serial.print(data+0);
   Serial.print(" ");
 }[/font]

[font=Microsoft Sans Serif]the result is strange:[/font]

[font=Courier]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[/font]

[font=Microsoft Sans Serif]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?[/font]

madepablo

#85
Sep 30, 2009, 09:01 pm Last Edit: Sep 30, 2009, 09:10 pm by madepablo Reason: 1
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!

walterr

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!

jluciani

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
www: http://www.wiblocks.com
twitter: http://twitter.com/wiblocks

walterr

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)

walterr

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

Code: [Select]
#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);
 }
}

Go Up