Update 2020-09-24: At the time this post was originally made, most of the Chinese sellers on eBay were selling real (but not guaranteed by Maxim) DS3231 chips that generally kept good time. At some point they started selling DS3231M chips without updating their listings (which described the item as being the more-accurate -SN variant). Today, it appears that whatever stocks of real DS3231 chips have been depleted and many people have contacted me to say they’ve ordered the common “DS3231 and EEPROM” items from eBay, AliExpress, Amazon, etc. and the chips are wildly inaccurate even though they’re marked as DS3231. Buyer beware. It’s probably a good idea to buy chips for serious purposes from legitimate distributors.
Dallas Semiconductor, now owned by Maxim Integrated, is well known for making some excellent real-time clocks (RTCs). Take, for example, the DS1307: it’s simple, works with essentially any cheap 32,768 Hz watch crystal, is easily accessible over I2C, and is extremely power efficient (500nA current when running the oscillator on battery power).
As great as it is, the DS1307 has a major drawback: it relies on an external crystal and lacks any sort of temperature compensation. Thus, any change in temperature will cause the clock to drift. A 20ppm error in the frequency of the crystal adds up to about a minute of error per month. Not so great.
Fortunately, Maxim also offers the DS3231, which is advertised as an “Extremely Accurate I2C-Integrated RTC/TCXO/Crystal”. This chip has the 32kHz crystal integrated into the package itself and uses a built-in temperature sensor to periodically measure the temperature of the crystal and, by switching different internal capacitors in and out of the crystal circuit, can precisely adjust its frequency so it remains constant. It’s specified to keep time within 2ppm from 0°C to +40°C, and 3.5ppm from -40°C to +85°C, which means the clock would only drift 63 and 110 seconds per year, respectively. Very cool.