Running the DS3231 solely from battery - I2C comms

Hello!

I'm hoping someone can answer this.

I've followed this guide here.

Everything is connected up and working, the device appears to be running solely from battery, interrupt from alarm is working, and can be set via I2C register writes.

However looking at other posts, it seems to suggest you must supply power to the device via the VCC pin in order to write to registers on the ds3231.

See here for example.

Does anyone know if this is correct? It seems to be working fine in my case with new module I have setup and configured. Previously I followed the above advice and connected the VCC pin to high when wanting to write to it, and powering it down when finished. However with this new module all seems fine with VCC set to ground, as the datasheet suggests it should be when operating from battery.

I suppose it could be that the device is leaching power from the SDA/SCL pins, but I'd be interested to see if anyone has any guidance with how this is expected to work.

Take a look at the data sheet. The battery is a backup battery for times of power lost. Of course Vcc should be connected.
DS3231.pdf (maximintegrated.com)

The problem is the SDA and SCL pins. Those lines have pullup resistors to Vcc. If Vcc is grounded, then they become pull-down resistors, and I2C communications won't work. But if you have removed the pullup resistor pack, and have pullups to Vcc somewhere else, then it should work.

I used the article you linked recently.

Yes, you need Vcc to read and write. If you see something in a data sheet that sez or implies otherwise, please point that up.

Yes, maybe you are getting ghost power from the I2C lines.

In my device I turn off the I2C outputs and remove power from the pullups during deep sleep.

A good meter is essential to ferreting out tiny bits of current here and there. You will surprise yourself as you find and remove the uAs.

A few mosfet switches and more thinking is the key. I’ll need a new meter to measure the current my device now uses whilst asleep.

a7

Thanks all for taking the time to reply.

I see there is conflicting thoughts though even in this thread :slight_smile:

@ShermanP yep I've removed the pullup resistor pack. What I've found though is that if the DS3231 is the only device on the I2C bus, then everything works fine, Alarms and writing over I2C works. So essentially I can set an alarm, sleep and then set another alarm without using vcc, only battery.

However as soon as another device is present on the I2C bus, this doesn't work. I assume the DS3231 is leaching power, and when 2 devices are present, they are both doing this, and there is not enough remaining current over the SDA/SCL lines for the DS3231 to draw from it.

@alto777 I can see this section in the datasheet:

To preserve the battery, the first time VBAT is applied
to the device, the oscillator will not start up until VCC
exceeds VPF, or until a valid I2C address is written to
the part. Typical oscillator startup time is less than one
second. Approximately 2 seconds after VCC is applied,
or a valid I2C address is written, the device makes a
temperature measurement and applies the calculated
correction to the oscillator.

That seems to suggest that on battery power, the device will start if a valid I2C address is written to it. So I'm really confused if this device can be fully functional on batter power with VCC grounded.

Is there something in the datasheet which says you must provide power over the VCC line before writing to it over I2C?

Do you have a new meter in mind which you can use to measure such low current? I'd be interested in purchasing one :slight_smile:

Yes, I see how you could interpret that quote from the data sheet. All I can say is I don't think so; obvsly it would be tricky to arrange a proper experiment. Casual googling turns up more fingers pointing at ghost power over the I2C; as I have said, I switched off the pullups and set the I2C lines to INPUT. Zzz…

As for meters, I can't pretend to be an expert or know what your own budget and constraints and goals may be, but check this thread out for starters.

I can say I have been very happy with my old TekPower TP4000ZC, still for sale, inexpensive. It also has a frequency / duty cycle settings which mean my "real" one gathers more dust than it otherwise might do.

a7

I don't think so.

What's the problem? You power it up via Vcc when your overall system is powered and operating. I²C functions properly, it draws virtually no current (but there is a matter of a link which might be used only if you wished to actually charge your backup battery). There is no doubt that this is how it is intended to operate. Why would you want to do otherwise?

My DS3231 pin 2 separate. and to backup battery gnd.it work ok.

If module VCC not on power.DS3231 I2C no reaction.

I think. We talk VCC is DS3231 chip the VCC pin. is no't module VCC pin. :slightly_smiling_face:

If you've removed the pullup resistor pack on the module, then there should be pullup resistors installed on SDA and SCL somewhere else. If you have not done that, but it still works, then perhaps the Wire library is using the internal pullup resistors on A4 and A5. But those resistor values are too high, and may not work well if two or more I2C devices are connected.

You might try connecting pullup resistors (4.7K to 10K) from 5V to SDA and SCL back on the Arduino, and see if it works properly when two I2C devices are connected. Of course the two devices must have different addresses. That's assuming the second I2C device doesn't also have pullups. If it does, they should be enough, and I don't know why it wouldn't work.

The DS3231 will absolutely work properly with its Vcc pin grounded so long as power is available at Vbat. And if you've removed the resistor pack, then connecting 5V to the Vcc pin of the module should have no effect because nothing is connected to that pin anymore.

Again, thank you to all who have replied. One thing I missed from the article I posted in the first message, it has this part:

I made an error during some recent run tests, where I forgot to connect the RTC’s Vcc line jumper to the digital pin for power (see addendum: 2017-04-15) . The test ran without a hitch for several days (>6000 RTC temp readings & alarms) with the Vcc pin left floating, and power provided only through the Vbat line. I had assumed that high-speed I2C communications would fail in this situation, but after digging through the data sheet – it turns out that the DS3231 is fully functional on Vbat. With this realization in mind, I have changed the way I modify these RTC boards for low power sleeping:

snip

The DS3231’s Vcc pin is now connected to GND, rather than being tied to a digital pin on the Arduino for power during logger run-time operations.

So indeed according to his experimentation it should work. @ShermanP thanks for the pointers, I'll see if I can get it working myself.