Just got DS1302rtc for little project and cannot figure out how to make it work. I have tried few different libraries and the problem still exists. 1 second it showing 00:00:00 time and 00:00:2000 date the other second it showing good time.
Delta_G:
Why? I see lots of libraries that are written by people who obviously missed some important point. I just dealt with one the other day that used a SoftwareSerial instance on pins 0 and 1. So the fact that some library did it doesn't impress me. Why would one want to bit bang that when there is a hardware SPI port right there already?
One possible explanation is that SPI hardware can't be used (or, no one has figured out how) with this device, as suggested by this Playground entry. There is this discussion as well.
A quick search failed to turn up an SPI hardware implementation of the protocol.
jremington:
I suggest to use a standard I2C RTC module like the DS1307 or (much better) DS3231.
These are readily available and are what most people use, so there is much more help available if you run into trouble.
yeah I heard that... I have already ordered DS3231. But shipping to my country sometimes takes more than 1 month so I thought to play around with DS1302 while waiting because it's the only module what local store can offer.
The DS1302 is a real time clock but works with a trickle charger for battery back up. Unless you specifically want that feature, most folk start with the DS1307 or the more accurate DS3231. DS1307 is available in DIP8, but the 3231 comes in a SOIC package - just use a SOC to DIP adaptor
There are libraries for both for example DS1307RTC (the DS1307 and DS3231 are pretty much interchangeable with these libraries if you just want the basic times and dates)
You will also need the Wire.h library for comms and TimeLib.h to really get at the functions.
If you really want to get down to basics and work without a specific clock library, have a look athttp://tronixstuff.com/2014/12/01/tutorial-using-ds1307-and-ds3231-real-time-clock-modules-with-arduino/
Have a look at Paul Stoffregens Github repository (look for DS1307RTC library)
Jack Christensen has a TimeZone library if you want daylight saving etc.
Just using the DS1307RTC library and one of the examples like ReadTime or SetTime will get you started
The TimeLib library takes the time from the RTC - nice combination