Using an external DS1672 RTC
The DS1672 is an easy way to add an external RTC when the internal RTC isn’t available. It’s a simple 32bit seconds counter that can be set with Unix time using the standard DateTime class. All that’s required is a 32.768kHz crystal and capacitor. A 1000uF capacitor will keep it running without power for at least 2hrs.
It’s available in voltage ranges from 2V to 3.3V. The 3.3V version should be used with the FEZ mini and only connected to one of the 3.3V supply pins.
To initialize, create a new class instance with the true option which enables the trickle charger for the capacitor. If there isn’t anything connected to the Vbackup pin, use false and ground the Vbackup pin. Only ground the Vbackup pin with the trickle charger off or it may damage the chip
static DS1672RTC RTC = new DS1672RTC(true);
It can be set with the standard DateTime function.
RTC.Set(new DateTime(2010, 10, 13, 15, 22, 00));
The basic read function will return the seconds which can run through the UnixTimestampToDateTime function and return a standard DateTime object.
The counter can be a few seconds off per day when there isn’t a proper ground plane to shield the crystal from noise. It helps to keep the crystal lines as close to the counter as possible.