From Counter to Clock With RTC DS-1302

by GandaU in Circuits > Arduino

2650 Views, 9 Favorites, 0 Comments

From Counter to Clock With RTC DS-1302

20160207_112043.jpg
This time I would like to modify from our previous counter to become a simple clock by using DS-1302 RTC chip.

DS-1302 uses 2 wire interface used by Atmel which is old version of I2C.

Since more space on the left side of the board is needed, we reassembly the component from the counter to the right. And for clarity, the 0.56" 7 segment will be used.

Additional Component

CRY32.jpg
CRY32-1302.jpg
ds1302module.jpg

- All component in counter

- Crystal 32 KHZ

- RTC DS1302 IC

- Resistors (3 X 10K for pull ups)

- 3V watch battery or 100uF capacitor with 1K pull ups

Or if you prefer you can use separate DS1302 module with battery and connect to to your breadboard.

Place DS-1302 Chip

ds1302pinout.png
ds1302pullups.jpg
2016-02-07 11.34.24.jpg

Since we used up all of our digital pins, and we still need 3 more pins for communicate with RTC. So we will use analog pins as GPIO. That way we can connect DS-1302 chip without extra hardware.

In image above we can also use 1 resistor from pin 4 to ground instead of pull ups. Also capacitor as substitute of watch battery (just for sake of prototyping, not to be used as production).

Upload the Code

Screenshot_1.png
Before upload the code, please change the set time to your current.

rtc.halt(false);

// Make a new time object to set the date and time.

// Sunday, September 22, 2013 at 01:38:50.

Time t(2013, 9, 22, 1, 38, 50, Time::kSunday);

// Set the time and date on the chip.

rtc.time(t);

After all finish then, upload program. to test.

If all ok, you can comment the "rtc.time(t)" so that it won't reset to particular time upon boot up.

Now you can show of the clock in your living room or put it in transparent box.

Cheers.

Downloads