RTC ds3231 returning the wrong year

Every thing seems to work, except it displays the year 1915, not 2015. Library is:

  • DS3231.h
  • Arduino Library for the DS3231 Real-Time Clock chip
  • (c) Eric Ayars
  • 4/1/11
  • Updated to Arduino 1.0 By john Hubert
  • Feb 7 2012

Is there another library I should be using?

Thanks for taking the time to read!

Gil

TimeandTemp.ino (5.65 KB)

Hello and welcome :slight_smile:

I use this library. Try it :wink:

gilbertg:
Every thing seems to work, except it displays the year 1915, not 2015. Library is:

  • DS3231.h

Then your library is wrong.

The clock itself stores always two digits for the year.

So if the clock runs at year 15 and your library adds 1900, it will display 1915.

And if the clock runs at year 15 and your library adds 2000, it will display 2015.

If this is the only error in the library, perhaps you can find and fix it in the source code?

I tried the other lib guix mentioned. A boat load of compile errors. I looked in the original lib to see where it added the 1900, and I don't have enough experience to notice it. I'm a total noob, so I'll stick my nose back in the books and get some more learning under my belt. I don't expect anyone to do it for me. Thanks again Very Much for the quick replies! Don't worry...I'll be back with more questions, I promise! :')

The DS3231 does have a century bit (the high bit of the month register) but I don't know of any library that uses it.

I tried the other lib guix mentioned. A boat load of compile errors.

The Christensen library recommended by guix is rock solid, and is the one I use. If you just replaced the # included library version, you will get compile errors due to the different syntax between the libraries.

gilbertg:
I tried the other lib guix mentioned. A boat load of compile errors. I looked in the original lib to see where it added the 1900, and I don't have enough experience to notice it. I'm a total noob, so I'll stick my nose back in the books and get some more learning under my belt. I don't expect anyone to do it for me. Thanks again Very Much for the quick replies! Don't worry...I'll be back with more questions, I promise! :')

I had the same problem today. I found the DS3231.ccp file had mention of the year 1900. I'm not good with libraries (Noobie), but I replaced 1900 on line 76 with 2000, as well as line 117, then saved the file. No idea what I did, but the date now comes up as 2015.

PS. It has fixed one problem, but may have stuffed up a future one (my guess is turn of the century 2100). But my guess is that no one will be using this code then. We'll probably program thru our home robotic assistance, or maybe in layman's language (via Siri) or maybe even telepathically!

DS3231.cpp (9.79 KB)

cattledog:
The Christensen library recommended by guix is rock solid, and is the one I use. If you just replaced the # included library version, you will get compile errors due to the different syntax between the libraries.

I agree. Nothing touches it.