Keeping time without an RTC

I recently purchased a DS1307 RTC chip from Digi-key, and put together a small I2C RTC on proto-board with a 37khz crystal and the requisite decoupling capacitors. Recently I came across a cheap clock kit on Ebay. I looked at the board and it is a simple 4 digit 7 segment display, Piezo buzzer, atmega328 chip with 16mhz xtal and 22pf caps. Interestingly they provided the c code for the clock and I looked at it, since I have recently build a clock using the DS1307 chip and I wanted to see what they did.

I noticed that they are using the raw c using the AVR libraries which was interesting for me as I wanted to see what a straight c program looked like without the Arduino magic. Interestingly it looks like they created an internal software clock using the on board internal oscillator as a timing source. My question is the following: What is the advantage of using an RTC external IC? From their code it seems like they used a little more code and variables to manage the time, but not much. SparkFun has a similar clock with source available as well. The link is below:

https://www.sparkfun.com/products/10930

The advantage of an external RTC is that is has a battery. It keeps running if the Arduino is turned off.

The 16MHz crystal of the Arduino is not very accurate for a clock. A RTC has usually a better clock. For something more accurate, use the DS3231. That RTC has an internal crystal and temperature compensation.

One reason that clocks based on the Arduino crystal tend not to be accurate is that the crystal or resonator used has poor tolerance and the frequency is not 16 MHz, as assumed in the code. However, with the clock kit you can calibrate the internal tick, to correct for the inaccurate crystal. The result is that such a clock can be quite accurate, if the temperature is held constant.

In the case of the Sparkfun clock kit you linked, this bit of code sets the clock calibration:

    //Prescalar of 1024
    //Clock = 16MHz
    //15,625 clicks per second
    //64us per click    
    
    TCNT1 = 49911; //65536 - 15,625 = 49,911 - Preload timer 1 for 49,911 clicks. Should be 1s per ISR call

By making incremental changes to the constant 15625, the resulting clock can be adjusted to an accuracy of slightly better than 3 seconds per day.

DS1307 RTCs in my experience gain or lose many seconds per day (20 seconds per day in one case) even at constant temperature, because the board manufacturers tend to use low quality 32 kHz crystals.