Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, a web toolkit designed to help citizens, conservation practitioners, municipal decision-makers, researchers, educators, and students advance knowledge and stewardship of fresh water. New to EnviroDIY? Start here
Tips & Pointers

DS3231 Real Time Clock (RTC) date conversion

Real Time Clock (RTC) modules like the DS3231 chip (found on the ChronoDot and Seeeduino Stalker v2.3) keep track of the date and time for a datalogger circuit.  The module can output the number of seconds since January 1, 2000 as an integer, which can be very handy for recording a time stamp with your sensor data.  However, 1/1/2000 is not a common starting point for most epoch calculations.  They usually use what most people call Unix Time, which is the number of seconds since 1/1/1970.   So there can be issues if you’re trying to convert between DS3231 epoch time and Unix Time.  The simplest method is to add 946684800 seconds (the number of seconds between 1/1/1970 and 1/1/2000) to the DS3231 time to get Unix Time.

So:  DS3231Time + 946684800 = UnixTime

But there can also be an issue if you’re working with dates in MS Excel.  It considers 1/1/1900 as the starting point and expresses date as the number of days (not seconds)  since that starting point.  So if you want to convert and Excel dates to UnixTime, here’s the forumla:

(ExcelDate – 25569) * 86400 = UnixTime

And as shown above:   UnixTime – 946684800 = DS3231Time

0 0 vote
Article Rating
Notify of
Newest Most Voted
Inline Feedbacks
View all comments
5 years ago

How do I convince a DS3231 to output seconds since 1/1/2000? I can’t find anything in the DS3231 data sheet describing such a function.

Would love your thoughts, please comment.x