DS1307 does not keep running on battery power (ESP8266/3.3V Arduino)

I've been searching everywhere and I couldn't find a concrete answer. Any help or pointers are appreciated!
I have a board that has a DS1307 (Tiny RTC) module connected to the 3.3V ESP8266 chip, and have identified an issue with the chip ceasing to work on 3.3V input when the battery is installed. The solution was to increase the module's VCC voltage to 5V.
With that, I thought I solved the problem for good and I could resume working on other parts of the code and circuit, but then found out that the clock stops running when the 5V power is removed.
The module has been modified as such to run safely on the 3.3V I2C bus and CR2032 (not LIR2032) battery. (Red diagonal line means that component is removed, green line means it's been replaced with a wire link)
IMG1704684273
The code used is the same as RTCLib sample code but cut down to only use hours, minutes and seconds:

#include "RTClib.h"

RTC_DS1307 rtc;

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

#ifndef ESP8266
  while (!Serial); // wait for serial port to connect. Needed for native USB
#endif

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    Serial.flush();
    abort();
  }

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running, let's set the time!");
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
}

void loop () {
    DateTime now = rtc.now();
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
    delay(1000);
}

The code works as intended when the power is supplied, however the module stops counting seconds after about 5~7 seconds when the power is cut. For example:
Power removed at 12:00:00, then wait 1 minute = When power is restored, it starts counting at 12:00:07, not 12:01:00 or such

The clock does not need to be very accurate, however it should at least keep the timer going when the power is cut. What is happening here? Any help would be appreciated!
(Note: The same deal happens when it's connected to 3.3V Arduino Nano. It's not a problem of the MCU itself, it seems.)

TL;DR:

  1. The module works fine with and without the battery on 5V power as supplied.
  2. The module does keep the last time it has counted to when the battery is connected and the VCC power is disconnected.
  3. The problem is that it does not keep running to keep the time current, and gets stuck few seconds after powering off.
  4. The MCU is not the problem. This symptom happens on both Arduino and ESP8266 using 3.3V I2C communication (but the module still gets 5V)
  5. What I'm looking for is a solution to the problem of the clock not running when it's on battery power. NOT it straight-up not working.

The data sheet says the device holding the information has a battery:

56-Byte, Battery-Backed, General-Purpose RAM with Unlimited Writes

Yes, that is true, but isn't the point of a real-time clock... it being a clock? As in it keeps track of time no matter what happens to the rest of the circuit? If putting a battery in it doesn't keep it going, there is something seriously wrong with it, and I can't figure out why.

It is. You need to retrieve it.

DateTime now = rtc.now();

Inside the loop retrieves the time, and has nothing to do with this issue.

We won't be able to either, unless you post a correct, revised schematic diagram of the circuit, after all your modifications have been verified.

Did you check for battery voltage presence on the appropriate pin of the DS1307 chip?

Absolutely, and let me quickly whip up the schematic.


This should be the final schematic after the modification.

  1. The datasheet for the DS1307 states that the minimum supply voltage is 4.5V. Like it or not, you'll need a 5V supply in your circuit somewhere, as well as level shifters on the SDA and SCL lines.
  2. Using a voltmeter, check the voltage at pin 3 of DS1307. I've had issues with batteries not making a connection in Chinese made battery holders.
  1. Yes, I have ensured that it runs at at least 4.5V (VCC-GND). The modification only decouples SCL/SDA line from VCC for 3.3V MCUs, and disables charging the coin cell. As I said, the module still runs on 5V line. (Moreover, if the I2C communication didn't work at all, the time wouldn't display and it should display "Can't find RTC".)
  2. Yes, it is getting full 3.2V from the cell.

It sounds like a bad module, do you have another to test it?

Yes, I have 4. I'll try the same modification on all of them, just in case.

See if you can get one to work. What Arduino are you using? The chip must have at least 4.5V to operate, here is a link to the data sheet I checked: https://www.analog.com/media/en/technical-documentation/data-sheets/ds1307.pdf Also you do not need level shifters on the I2C per data sheet: Serial Data Input/Output. SDA is the data input/output for the I2C serial interface. The SDA pin is open drain and requires an external pullup resistor. The pullup voltage can be up to 5.5V regardless of the voltage on VCC.

Arduino Nano, modified to run at 3.3V, and a ESP8266 development board. Both do work when 5V is supplied to VCC pin of the module, however at least with that specific module I used, it stops counting when that power is removed.

I tested a total of 7 modules, and here's the result:
Module 1: Keeps the time correctly
Module 2: Does not continue counting time after power is cut
Module 3: Ditto
Module 4: Counts for 2 seconds, then stops after power is cut
Module 5: Ditto
Module 6: Counts for 2~4 seconds, then stops after power is cut
Module 7: Counts for 5~7 seconds, then stops after power is cut
All 7 modules have the same modifications done to them, so I'm lost as to why only one seems to be working correctly.

What about Module 6 ?

Oops, forgot to copy over that line. It's fixed now.
Regardless, I'll try to transplant some DS1307Z chips I have, just to see what happens.

Could you post the original schematic showing what was there before your modifications?

Also, it appears R7 is not populated. Is that correct? Is it that way on all your modules?

Actually, R7 is populated on all of the modules I've tested. It's odd.
Here's the unedited original schematic:

I don't understand the circuit, particularly R7, R4 and R6.

When the main power to the module is turned off, is Vcc disconnected, or is it grounded? If it's diconnected, you have 683.3K resistance to the SQW OUT pin. Why would they do that?

Well, it just seems it's not oscillating on coin cell power. I don't know why. Does an unmodified module have the same problem?

I'm gonna turn in. Back tomorrow.