Any idea what could be causing this? I have a diode between my DS3231 and my board as i had issue of my DS3231 completely fucking up the time without it when i unplugged my board
The DS3231's time drift is about 0.67 sec in a day. A battery backed up DS3231 keeps maintianing the time of the day even the power is emoved from the Arduino Board.
Therefore, the deep sleep mode of the MCU has noting to do with the time drift of your RTC. It should be something wrong with you codes that do not read the time correctly from the RTC.
Nope, the issue only arises when using going to deep sleep
The rtc works fine otherwise, but if i go into sleep mode and let it run for a few hours, the RTC will have drifted, which doesnt happen otherwise
You probably have a fake or counterfeit DS3231. They are quite common.
My genuine DS3231 chips keep track of time to within about 1 minute per year, regardless of whether they are standalone, or connected to a sleeping or running processor.
For help on this forum, please provide the required information. The "How to get the best out of this forum" post summarizes what you are expected to post, and how it should be formatted.
The retain time when powered off and when running, If I put a delay at the end of each loop all is fine, if I use powerDown for 1 second then time drifts wildly, like 5 seconds per minute.
here's my sketch and board design
I'm now experimenting wit idle instead of powerdown, eventually if all else fails I'll just remove the deep sleep, the arduino is hooked up to a thing with a 10W neon tube inside, I don't think few milliamps make any real difference
The problem I'm having is that I can't think of a way I could make this happen even if I wanted to. Is the RTC still powered when the processor goes to sleep?
Also, could you post a schematic of your circuit that I can read without having to install Kicad?
Hey! thanks a ton for following up!
Got to the bottom of it, I've powered the I2c line from the main circuit tension regulator instead of the Arduino Vcc out, and swapped pullup resistors with 4.7k ones.
It's been running for 12hrs now without missing a minute.
Not sure if using smaller pullups was needed, tbh, likely powering the I2C bypassing the Arduino did the trick.
It's now drawing slightly more current on the I2C line, but that's perfectly fine, it's not battery powered anyway, and the big saving is enabling sleep mode.
Yes, the chip is marked DS3231M, and no, I don't have a clue either about how this can happen, I mean, I understand what fixed it, but definitely not how wonky power could have made the RTC run slow. And, btw, I'm 100% that's exactly what was happening, I had two identical RTCs running, one with sleeps and one without, after a few hours the one on the board doing the sleeps would be minutes behind, approx 5 seconds per minute doing 1sec sleeps, around 1.25 doing 4s sleeps, which had led me to think it wasn't about the time spent sleeping, but the number of wakeups.