DS3231 Drift when going into deepsleep

Hi!

I've been having this issue where my RTC DS3231 drifts when the board goes into deep sleep, despite it being accurate when i dont go into deep sleep

My code works by synching my internal clock (using the time library) to the DS3231 everytime i wake up from deepsleep using the watchdog timer

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

Publish your code so we can start pinpointing the problem

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.

1 Like

check the github i linked

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

Please, post the minimum codes that will reproduce the fault. Do few hours mean 2/3 hours?

Could you give us a schematic? I don't understand where the diode is placed. Also, how much drift are we talking about?

Can you post your code here?

That will make this thread self-contained so it will work better for future reference.

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.

+1, same issue, I'm using these modules I got off Amazon

link

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 :grin:

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?

Is your RTC chip marked DS3231M?

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.

thanks again!

Maurizio

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.