This library was made because I wanted an easy way to interface and use the DS1307 I²C Real-Time Clock without the need for the Wire library.
The DS1307 serial real-time clock (RTC) is a low-power, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially through an I²C, bidirectional bus. The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with AM/PM indicator, but the library only supports the 24-hour mode. The DS1307 has a built-in power-sense circuit that detects power failures and automatically switches to the backup supply. Timekeeping operation continues while the part operates from the backup supply.
DS1307.zip (Filesize is 373.64 KiB. Downloaded 35009 times)
A few demos are included to demonstrate most of the functions. This is a multi-platform library that will work with several different development board types.
For a full list of changes please see the file version.txt included in the download.
Nice to know:
The DS1307 is a 5 volt device and operating it at 3.3 volt may cause issues. If you experience issues communicating with the DS1307 the first thing you should do is make sure it is running at 5 volts. Remember to use proper level shifters for the SDA and SCL lines if you are using a development board running at 3.3 volts.
This library will default to I2C Fast Mode (400 KHz) when using the hardware I2C interface.
I highly recommend using the DS3231 (or DS3232) instead of the DS1307. While the DS3231/DS3232 may be slightly more expensive than the DS1307 it is much more accurate due to the internal TCXO (temperature-compensated crystal oscillator) and crystal. This also means that you don’t have to use an external crystal like you have to with the DS1307.