I have the known DS3231 cheap RTC. I use LIR2032 battery, and although in the past i had problems keeping time when rtc wasnt powered from the microcontroller, i managed to fix that.
Now, i see that it keeps time, but the time it gives is something like 5 minutes earlier. I have some days to use it, so i guess if its not powered from the microcontroller it starts loosing time.
I had tested it in the past and the time was fine, but now maybe i had it without external power for more time, so the onboard battery is not so reliable.
Has this happen to anyone else? Its like it lost 5 minutes the last 1-2 weeks..
edit: it was my fault. It seems to work fine, my code stuck running in the next Serial print (for these 5 minutes) and i didnt notice it..
From the data sheet: Status Register (0Fh)
Bit 7: Oscillator Stop Flag (OSF). A logic 1 in this bit indicates that the oscillator either is stopped or was stopped for some period and may be used to judge the validity of the timekeeping data. This bit is set to logic 1 any time that the oscillator stops. The following are examples of conditions that can cause the OSF bit to be set:
The first time power is applied.
The voltages present on both VCC and VBAT are insufficient to support oscillation.
The EOSC bit is turned off in battery-backed mode.
External influences on the crystal (i.e., noise, leakage, etc.).
This bit remains at logic 1 until written to logic 0.
Check that flag and have your software remember if it was ever set to a 1. This indicates a power problem.
Handling, PCB Layout, and Assembly: The DS3231 package contains a quartz tuning-fork crystal. Pick-and-place equipment can be used, but precautions should be taken to ensure that excessive shocks are avoided. Ultrasonic cleaning should be avoided to prevent damage to the crystal. Avoid running signal traces under the package, unless
a ground plane is placed between the package and the signal line. All N.C. (no connect) pins must be connected
to ground. Moisture-sensitive packages are shipped from the factory dry packed. Handling instructions listed on the
package label must be followed to prevent damage during reflow. Refer to the IPC/JEDEC J-STD-020 standard for
moisture-sensitive device (MSD) classifications and reflow profiles. Exposure to reflow is limited to 2 times maximum.
This should help you find your problem. This and much more can be found on the data sheet.
gilshultz:
From the data sheet: Status Register (0Fh)
Bit 7: Oscillator Stop Flag (OSF). A logic 1 in this bit indicates that the oscillator either is stopped or was stopped for some period and may be used to judge the validity of the timekeeping data. This bit is set to logic 1 any time that the oscillator stops. The following are examples of conditions that can cause the OSF bit to be set:
The first time power is applied.
The voltages present on both VCC and VBAT are insufficient to support oscillation.
The EOSC bit is turned off in battery-backed mode.
External influences on the crystal (i.e., noise, leakage, etc.).
This bit remains at logic 1 until written to logic 0.
Check that flag and have your software remember if it was ever set to a 1. This indicates a power problem.
Handling, PCB Layout, and Assembly: The DS3231 package contains a quartz tuning-fork crystal. Pick-and-place equipment can be used, but precautions should be taken to ensure that excessive shocks are avoided. Ultrasonic cleaning should be avoided to prevent damage to the crystal. Avoid running signal traces under the package, unless
a ground plane is placed between the package and the signal line. All N.C. (no connect) pins must be connected
to ground. Moisture-sensitive packages are shipped from the factory dry packed. Handling instructions listed on the
package label must be followed to prevent damage during reflow. Refer to the IPC/JEDEC J-STD-020 standard for
moisture-sensitive device (MSD) classifications and reflow profiles. Exposure to reflow is limited to 2 times maximum.
This should help you find your problem. This and much more can be found on the data sheet.
I've already read about these info. Thanks for pointing out. At the beginning the DS3231 couldnt keep time (i dont know what was the problem), and made a lot of things but i guess what helped was that i manually reset Control Register (0Eh) and Status Register (0Fh) to "default" values. I think this was the point that it started working correctly (i didnt change the battery and didnt do any hardware modification)
Where did you buy the 'DS3231 cheap RTC' from ?
i think it was from aliexpress..you can find them in the range 2-3 euros