For my AquaTank Control V2 project this is a necessary thing,
Arduino board can count time very well, BUT, as soon as you disconnect it goes back to zero.

This is where the DS1302 kicks in.
I bought it on ebay – Link
and decided to go for the Surface Mounted one to save space in my future project

ds1320

So here is a hook up guide and integration with my project

The DS1302 connect to the arduino using 3 digital pins like this:

ds1320-pinout

Or any other Pins, you will define this in the code.

The Code

Using the DS1302 Arduino library by Henning Karlsen.
The example code displaying the time with the serial monitor:

Please note once you have flashed the arduino once with the correct time you should comment out (add // in front) or delete lines 23-25 and flash it again:

//rtc.setDOW(FRIDAY); // Set Day-of-Week to FRIDAY
//rtc.setTime(12, 0, 0); // Set the time to 12:00:00 (24hr format)
//rtc.setDate(6, 8, 2010); // Set the date to August 6th, 2010

Integration

Integrating DS1302 RTC with 12864 LCD:

And the result:

IMG_20140409_114414

Have Fun Doing it Yourself 🙂