I've been making weather stations based on the Arduino. These weather stations take multiple weather measurements and store it to an SD card at a sampling time of approximately 0.1 Hz. Unfortunately, I have been experiencing a strange bug in the DS1307 real time clock that only manifests itself after a few days.
This is what happens: Approximately 3 to 5 days after the sketch first starts (It's not consistent), the RTC will fail randomly. It will fail in one of two ways. It will either get stuck on one time and continue to take measurements but log the same time over and over again, or it will change the date value to something meaningless, and log that over and over again.
Normal operation can be seen here (the dates are highlighted):
Getting stuck on one time can be seen here:
Meaningless values getting stuck can be seen here:
I've already tried replacing the chip but it did not do anything. It's on custom circuit board but I don't think that is the problem because the chip works fine initially, then fails after a few days. I thought it might be a battery issue but the DS1307 has its own battery backup. Finally, since all the failures seem to happen in the middle of the day, I thought the problem might stem from a heat issue. However, the maximum temperature seen inside the box is approximately 55C, while the maximum operational temperature for the DS1307 is 85C.
I am using Adafruit's RTClib (https://github.com/adafruit/RTClib
) and my code is found here: https://github.com/madvoid/LEMS/blob/master/Final/Final.ino
I understand my code is very long but even if you don't read it, are there any ideas on what might be going on? Is it a memory or overflow problem? I can produce more details about the code/hardware upon request. Thanks for any and all help!