4

Summary

I'm having problems with my RTC draining its coin cells quickly - fresh batteries are drained in a few months. The RTC is set to signal an interrupt every 5 minutes, and I wonder - if there is no other power attached to the circuit, is that enough to drain the coin cell?

Details and my troubleshooting:

Problems with my RTC - if I leave the circuit unpowered for a few days (so that the only power to the RTC is from the coin cell backup), the time resets to 00:00 January 1, 2000. This doesn't happen immediately when I unplug it. If I disconnect it from the computer, plug it back in the next day, the time is ok. If I leave it unplugged for a few days, then plug it in, the date is reset.

This suggests the battery is bad. So I tested it with my meter (and an 100 ohm load, as described here: https://www.youtube.com/watch?v=HcikzMG7mMU). And sure enough, the batter has dropped quite a bit from its 3V start value.

That's all good, except that this battery is only a few months old, and it should last for years in an RTC. I've got two batteries purchased in the last year and used in RTC modules, and both are now drained.

My current hypothesis is that, after I unplug my circuit from the computer, the RTC continues to run on the coin cell, firing interrupts every 5 minutes, and it is these interrupts that are causing the drain. Does this make sense? If not, what else could I check?

Setup

Breadboard arduino, DS3231 RTC on a breakout, connected

  • RTC SDA -> Arduino A4
  • RTC SCL -> Arduino A5
  • RTC GND -> Common GND
  • RTC VCC -> Common 5V (from ftdi/USB cable, when plugged in)
  • RTC SQW -> Arduino D2

The RTC is 'active-low', and the SQW pin is held at 5V between interrupts. With my multimeter, the brief drop to 'LOW' is undetectable. I also can't detect any current flow from the SQW pin with my multimeter.

Sketch

Including only the code related to the RTC (SD card and temperature bits removed).

/*-(Import required libraries)-*/
#include <Time.h>
#include <DS3232RTC.h> //source: https://github.com/JChristensen/DS3232RTC 

/*-( Declare Constants )-*/
const int wakeUpPin = 2;
#define resolution 5 // frequency in minutes to wake from sleep

/*-(Declare Variables)-*/
time_t t;
int nextLoop;

/****** SETUP: RUNS ONCE ******/
void setup()
{
  Serial.begin(9600);

  Serial.println();
  pinMode(wakeUpPin, INPUT);

  t = RTC.get();

  nextLoop = ((minute(RTC.get()) / resolution) + 1) * resolution;
  if (nextLoop >= 60) {
    nextLoop -= 60;
  }
  Serial.print(RTC.temperature());
  Serial.print(",");
  Serial.print(RTC.oscStopped());
  Serial.print(",");
  Serial.println(nextLoop); // the minutes when the next reading will be taken

}

/****** LOOP: RUNS CONSTANTLY ******/
void loop()
{
  t = RTC.get();

  Serial.print(year(t), DEC);
  Serial.print("/");
  Serial.print(month(t), DEC);
  Serial.print("/");
  Serial.print(day(t), DEC);
  Serial.print(",");
  Serial.print(hour(t), DEC);
  Serial.print(",");
  Serial.print(minute(t), DEC);
  Serial.print(",");
  Serial.print(second(t), DEC);
  Serial.print(",");

  goToSleep();
}


void goToSleep(void) {
    Serial.print("Sleeping until: ");
    Serial.println(nextLoop);
    Serial.flush();
    RTC.setAlarm(ALM2_MATCH_MINUTES, nextLoop, 1, 1);
    RTC.alarmInterrupt(ALARM_2, true);
    attachInterrupt(0, wakeUp, LOW);

    LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
    detachInterrupt(0);
    RTC.alarm(ALARM_2);
    nextLoop += resolution;
    if (nextLoop >= 60) {
         nextLoop -= 60;
    }
}

void wakeUp(){
  // Handler for the pin interrupt.
}
7
  • Sorry, that probably isnt why your battery is getting drained. Is there anything else connected to the battery other than the RTC? Commented Apr 10, 2016 at 1:42
  • Nothing else is connected to the coin cell - it's part of an RTC breakout board.
    – Tyler
    Commented Apr 10, 2016 at 4:04
  • Do you have another RTC to compare against this one in case its damaged in some non-obvious way? What was the voltage when you measured it after a few days and it couldnt power the RTC any longer? The coin cell is a CR2032, right? Commented Apr 10, 2016 at 4:11
  • If I remember correctly, interrupts are disabled while the DS3231 is not getting power (except through the battery). Are you saying the battery is drained after a few months of no-power, or after a few months of power (and sometimes no power). What breakout are you using? Some breakouts use rechargeable batteries. Putting a regular battery in those will damage the battery and would explain the short lifetime.
    – Gerben
    Commented Apr 10, 2016 at 18:10
  • 1
    If the DS3231 is connected to the circuit(power) and the Arduino itself is not powered down, then it shouldn't use the battery at all, alarms or no. Either some wire is connected wrong or the RTC should be swapped out to see whether the problem persists. btw, DS3231s have internal pullups. They work so well that if you have one on your I2C you do not want to add others because they are then in parallel, which reduces their effective resistance. Also, I2C is connected to analog pins (A4 & A5) so INPUT_PULLUP would not apply.
    – SDsolar
    Commented Apr 14, 2017 at 8:25

2 Answers 2

1

Check your battery, it is behaving like a rechargeable one without a charger. Mine have the letter "R" at the end of the part number. There are a lot of RTC modules that charge the battery. Conversely they are some that do not charge the battery. Are you powering it with something other then the coin cell.

-1

1) Could be a short in your PCB. As suggested, try another module if possible.

2) Shouldn't you somehow program SQW pin to be an interrupt? By default I remember it outputs a squarewave.

3) Try calling clearAlarm(); for your RTC to see how it goes.

4) Having the RTC sitting there, by connecting GND and a digital input from an Arduino, can you digitalRead(); the pin? That way you'll see if it keeps firing interrupts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.