DS3231 slow down

Hi everybody! I try to use ds3231 RTC, but it slow down. I made clear code on arduino Pro mini 5V . The code display only time. Then i turned off arduino and RTC works only on coin battery. After 2 days I turned it on and I get 4s delay on RTC time.

I checked voltage on battery and it is 3.32....

could you give me some adivce how to run it correctly?

I think 2 seconds per day is (almost) with normal tolerance. If this is not good enough then register 0x10 is an ageing offset that you can alter to fine tweak the clock speed.

I'm not an expert, but I saw in datasheet that DS3231 works on 2ppm, so the accuracy should be about 5s per month. Please correct me if I'm wrong.

kwow: I'm not an expert, but I saw in datasheet that DS3231 works on 2ppm, so the accuracy should be about 5s per month. Please correct me if I'm wrong.

Now I look, my datasheet for the DS3231 says 5ppm and a +-0.432 seconds per day tolerance so 4 seconds in 2 days is excessive. Is it a genuine Maxim IC or a Chinese cheapy?

thanks for help! i bought modules on ebay. One is ZS-042 and on second is only "LC" sign. Thats they look: http://i.ebayimg.com/00/s/NzAwWDcwMA==/z/UzoAAOxyFd1SKA37/$(KGrHqJ,!o4FI(f)kVNRBSK!37gVsQ~~60_35.JPG

The second (litle) i set up about 6month ago and right now it has about 16 min delay I thought that delay will be couple of seconds per year.

kwow: i bought modules on ebay. One is ZS-042 and on second is only "LC" sign. Thats they look: http://i.ebayimg.com/00/s/NzAwWDcwMA==/z/UzoAAOxyFd1SKA37/$(KGrHqJ,!o4FI(f)kVNRBSK!37gVsQ~~60_35.JPG

The second (litle) i set up about 6month ago and right now it has about 16 min delay I thought that delay will be couple of seconds per year.

Not relevant to your time problem but this might be worth a look for your ZS-042 RTC. 16 minutes in 6 months is bad. Probably worse than can be expected from a DS1307. For me the DS3231 (I have 3 on the go ATM) is about 1 second per week without any tuning.

I saw this link. I run RTC with Arduino Pro Mini 5V for 24 houres and i get delay to, but it is less then 2s. So it is quite better, but still bad. Could you tell me how did you connect your RTC? I use only SCL and SDA. How about SQW and 32K?

kwow: Could you tell me how did you connect your RTC? I use only SCL and SDA. How about SQW and 32K?

One I just use SCL/SDA/GND and poll about once per second. But later designs I use the SQW configured as 1Hz output to feed an interrupt pin on the Arduino. This saves me having to poll (and could even allow the MCU to sleep in low power systems) or delay waiting for ticks. I also use it to trigger a heartbeat LED to confirm RTC is working.

Thank you Riva, How do you think. Is it problem with module or code? Could you tell me where did you buy your RTC, or recomend me some more accurate RTC?

kwow: How do you think. Is it problem with module or code? Could you tell me where did you buy your RTC, or recomend me some more accurate RTC?

The problem could be with either module of code but best to start with the code first and then assume the hardware is at fault. I just bought some DS3231 chips (the 8 pin version) and just add the battery, decoupling and pullup resistors myself. I have just bought a couple of modules from eBay so when they arrive I will set them up and see how well they do.

I made some test. I run 2 DS3231 in almost same time. Both of them has realy close delay - to each other. I also suppose that they slow down much after 24h. i didn't confirm it yet.

Hi Riva, were you able to test your DS3231?

I set up 5 ZS-042 and leave for 4 days only with coin battery. After that time i check te time and every RTC gave me different resault. It was about 10 seconds lag. One of them has 2min delay. Could you tell me which libs do you use?

kwow: were you able to test your DS3231? They only just arrived and I set them both up Saturday morning so not enough time has passed yet.

I set up 5 ZS-042 and leave for 4 days only with coin battery. After that time i check te time and every RTC gave me different resault. It was about 10 seconds lag. One of them has 2min delay. Could you tell me which libs do you use?

I use a version of this library, tweaked with my own additions.

@kwow: post your code (in code tags)

Pete

Riva: I just bought some DS3231 chips (the 8 pin version) and just add the battery, decoupling and pullup resistors myself.

The DS3231 isn't available in an 8-pin version. Perhaps you mean the DS3231M. It uses a completely different compensation method and is less accurate than a DS3231.

I have been measuring my DS3234 (same as DS3231 except the interface is SPI instead of I2C). I bought the chip, soldered it to a simple SMC-DIP adapter board and plugged that into a breadboard. Straight out of the box, maintained with a CR2032 battery and at room temperature (range 16-26°C) it drifted forward 43ms in a 24 hour period. That corresponds to a drift of about 1 second every 3 weeks. By tuning the aging register I was able to improve this to a drift rate equivalent to about 1 second every 6 months, at least at room temperature.

If yours is drifting 2 seconds per day there's something seriously wrong.

thank you guys for replays, this is my code:

#include 
#include 

DS3231 clock;
RTCDateTime dt;

void setup()
{
  Serial.begin(115200);


  Serial.println("Initialize DS3231");;
  clock.begin();


  clock.setDateTime(__DATE__, __TIME__);
}

void loop()
{

  dt = clock.getDateTime();

  Serial.print("Raw data: ");
  Serial.print(dt.year);   Serial.print("-");
  Serial.print(dt.month);  Serial.print("-");
  Serial.print(dt.day);    Serial.print(" ");
  Serial.print(dt.hour);   Serial.print(":");
  Serial.print(dt.minute); Serial.print(":");
  Serial.print(dt.second); Serial.println("");

  delay(1000);
}

Could you tell me if code does matter if RTC isn't connected to arduino? I set it up and disconnect arduino. All DS3231 work only on battery

This

clock.setDateTime(__DATE__, __TIME__);

I think will set the RTC to the sketch compile date and time that will be at least a few seconds different to real time and maybe a lot more.

I use a different library to you but the principle I use should be the same. I check to see if the year is zero and assume date/time is not set if it is, else I just roll through setup of date/time.

  RTC.switchTo24h();                                  // Not really important but...
  RTC.readClock();                                    // Read the clock
  RTC.writeData(0x0E,0x00);                           // Enable 1Hz output on INT pin
  if(RTC.getYear() == 0){                             // If Year = 0 then clock probably not set
    eAdjust();                                        // Call Adjust Routine
    RTC.setClock();
  }
  RTC.getFormatted2k(formatted);
  Serial.println(formatted);

I've had problems with RTC slowing down when I read it very frequently, such as once a second as you are doing. Change your code to print the time once every five minutes and see if it loses as much time as before.

  delay(300000L);

Pete

el_supremo: I've had problems with RTC slowing down when I read it very frequently, such as once a second as you are doing. Change your code to print the time once every five minutes and see if it loses as much time as before.

Reading the time registers has no effect on how well the RTC keeps the time. If you see benefit from reading the registers less frequently it only means that something else is wrong.

It really sounds like the OP has a sketch that SETS the time every time it's run.