Hey guys.
Iv been working on a timing based project with an arduino mega and RTC chip.
Im using a DS3231 RTC and have noticed the time is drifting more than it used too now that im taking a reading from the RTC more often within my sketch after adding more functions.
Im using the DS1307RTC Library and using the call "time_t t = now()"
Is this even possible or would there be other things which could be causing this time drift? Its gone from about 1 seconds per week to around 1 seconds per 24 hours.
If my maths is right that's 11ppm? If so it's way off as 2-3ppm would be considered normal. Why this would happen I don't know, reading it should have no effect.
DS1307RTC Library
Is that lib for the 3231 as well?
Post your code, possibly there's something in there t cause a problem although I can't think what would unless you are also setting the time as well
Horendus:
Could the extra drift be because of the temperature being around 30 - 40 degrees C these past few weeks?
Bingo! How south are you from the equator?
Your crystal frequency depends on temperature. To have a more accurate reading, you either get something that has a temperature sensor to compensate the reading or crystal in an oven so it is maintained at a constant temperature.
Temperature was my first thought but that's a TCXO.
Accuracy ±3.5ppm from -40°C to +85°C
So maybe you could have a 7ppm swing if it moved from the extremes. You've gone from about 1ppm to 11ppm, that seems out of spec unless I got my numbers wrong (quite possible).
A long time back (well over a year ago :|) another poster had the same problem with clock drift but I cannot find the post with the search on the forum. The cause was found to be a code error where the time was being requested from the chip to often.
Riva:
A long time back (well over a year ago :|) another poster had the same problem with clock drift
I had exactly the same thought, but I don't remember who it was. As far as I remember it, the theory was that the RTC module was so busy handling I/O that it was missing clock events.