DS1307 Real time clock on a breadboard
- Tuesday, January 26 2010 @ 04:46 pm GMT
- Views: 96,762
Heres my simple real time clock on a breadboard.
Using the DS1307 http://www.glacialwanderer.com/_blog/blog2008/04_April/DS1307.pdf
The breakout boards you can buy seemed a bit expensive so I decided to hook up the cheap components on a breadboard to try out on my Arduino.
The Crystal is 32.768kHz.
The battery is a 3v coin cell in a holder.
Heres a schematic of the breadboard.
The photo doesn't completely match the schematic but the wiring and pins are correct.
Thanks to http://code.rancidbacon.com/ElectronicBreadboardTemplates for the inkscape template.
I used the code from this forum topic http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1191209057
You need to install the DS1307 library from there.
This code was compiled on version 13 of the ide with a 328p but will work with a standard arduino.
#include <WProgram.h> #include <Wire.h> #include <DS1307.h> int rtc[7]; void setup() { Serial.begin(9600); /* RTC.stop(); RTC.set(DS1307_SEC,1); RTC.set(DS1307_MIN,57); RTC.set(DS1307_HR,17); RTC.set(DS1307_DOW,4); RTC.set(DS1307_DATE,18); RTC.set(DS1307_MTH,2); RTC.set(DS1307_YR,9); RTC.start(); */ } void loop() { RTC.get(rtc,true); for(int i=0; i<7; i++) { Serial.print(rtc[i]); Serial.print(" "); } Serial.println(); delay(1000); }
To initialy set the time uncomment the RTC.set lines and change the values.
Once youve done this the clock is set and the 3v battery keeps the time.
Eventually its going to be incorporated in my main project.
A temperature logging device with one wire temp sensors ,web server, serial lcd display, buttons and using the 328p. But its an ever evolving project. Once I get the time tied up with the temp data, Ill be nearly there.