Accurate DS3231 Real Time Clock as Alternative to DS1307

We have put together a lot of controllers which required a real time clock (RTC) – in particular dataloggers and other timers running over long periods of time which were required to do (or record) operations at specific times through the day consistently over weeks and months.

DS1307 real time clock (RTC) module for Arduino

Pictured above is a DS1307 module. These are available from just £1 including delivery from China/HK via eBay – see here: DS1307 Modules.

With a backup button cell (e.g. CR2032) on the underside of the module, these DS1307 modules will keep time even when disconnected from the main power source for months and even years on end. However, in our experimental projects (using this RTC with an Arduino for dataloggers amongst other things), we have found these DS1307 modules to vary hugely in their time-keeping accuracy – some gaining/losing a few seconds per day, and others gaining/losing as much as 3-5 minutes per day. While they have proved to be very consistent – i.e. a unit which gains 3 minutes per day will gain 3 minutes per day every day – having to test each unit individually over a few days and then modifying the Arduino project code to cancel out errors is not practical.

Some of the error is caused by ambient temperature changes affecting the accuracy of the timing of the crystal resonator. Some more of the error is also caused by the quality of the crystal itself and its attachment to the PCB in these economical modules.

DS3231 Real Time Clock (RTC) module for Arduino

Pictured above is an alternative to the DS1307 which we have found to be far superior in its time keeping accuracy which uses the DS3231. These are now also available on ebay from just £1: see here: DS3231 modules.

In extensive testing we have found the time-keeping of these modules to be excellent. The DS3231 chip on the module is marketed as being accurate to 2ppm (parts per million), which means less than one second lost or gained every 5 to 6 days. The units we have tested thus far have all come in at under 1ppm accuracy, so a couple of seconds at most lost or gained per month.

This accuracy is achieved in part by the incorporation of a temperature sensor in the DS3231 which can compensate for changes in ambient temperature. The measurements from this temperature sensor are also accessible to the user (accurate to +/- 3 Celcius) which makes for a handy extra feature. These DS3231 modules also have 32kb of available EEPROM memory which can be utilised by your projects, and many other useful features.

Click here for a very simple DS3231 introduction  from the Instructables website. If connecting a DS3231 module to an Arduino, you need to install the Arduino DS3231 Library from here which includes quite a detailed manual document to help you get started setting and accessing the stored time and temperature etc from your DS3231 module.

One thing to note is that due to recent changes to air mail postage rules, most of these modules are no longer sent out with a button cell (backup battery) provided (even when the eBay listing has one pictured). You will therefore need to source yourself a CR2025 or CR2032 button cell locally if you have a project necessitating backup for the time keeping.


Leave a Reply