DS3231 not retaining time.

Hi, I've been trying to interface with RTCs marketed as "DS3231 for Pi" primarily for their small footprint. The demo code works fine however the RTC does not retain time. Mine came without a battery, so I spot wielded two wires onto a 3v CR2032 battery and soldered the wires on the contacts on the board. However, this doesn't seem to have any effect, the RTC does not retain time.

I then soldered a 10 microfarad electeolytic Capacitor as a backup Battery. Surprisingly, the RTC seem to store time but as the voltage drops below 2.8v, the problem again comes to surface. Does anyone have any experience with these modules? What might be done to restore its function. Why doesn't a standard Lithium cell work? Below is the reference image of the DS3231 module I'm working with. I have three of them and they all exhibit the same behaviour.

Did you check the voltage of the lithium cell? Once welded & soldered, did you check the voltage at the Vbatt pin on the ds3231?

PaulRB:
Did you check the voltage of the lithium cell? Once welded & soldered, did you check the voltage at the Vbatt pin on the ds3231?

Thank you Paul for the consideration. The battery gives a steady 3.0 volts and the same is reflected at pin 14 of DS3231. In fact this is puzzling as the facts seem to tally, but the module does not function as intended. Is there any other thing I might have overlooked?

How long did you leave the battery to charge?

Did you check if the battery is rechrageable or not? If the PCB gives a trickle charge (usually just a limiting resistor to the battery terminal + , then you should install a rechargeable battery. If not, then a normal lithium cell will do.

These types only trickle charge very slowly and I would suggest leaving it with power connected to charge it up for at least 2 days.

The other things could be a duff battery or the localised heat when you 'spot welded' the wires damaged it internally.

Or maybe you accidently shorted it while spot welding it (like putting it in a metal vice or holding with metal pliers). That would discharge it very fast and again could cause damage.

Your best bet it is to get some battery holders and solder them instead, or a connector direct to the pcb.

Don't forget that for pi it is 3.3v logic and 3.3v or 5v supply (can't tell from the photo) - So again make sure all this is correct. Are you using 3.3v or 5v arduino? What are the specs for the pcb 5v or 3.3v?

Of course it could also be a bad module that is faulty....

skywatch:
How long did you leave the battery to charge?

Did you check if the battery is rechrageable or not? If the PCB gives a trickle charge (usually just a limiting resistor to the battery terminal + , then you should install a rechargeable battery. If not, then a normal lithium cell will do.

These types only trickle charge very slowly and I would suggest leaving it with power connected to charge it up for at least 2 days.

The other things could be a duff battery or the localised heat when you 'spot welded' the wires damaged it internally.

Or maybe you accidently shorted it while spot welding it (like putting it in a metal vice or holding with metal pliers). That would discharge it very fast and again could cause damage.

Your best bet it is to get some battery holders and solder them instead, or a connector direct to the pcb.

Don't forget that for pi it is 3.3v logic and 3.3v or 5v supply (can't tell from the photo) - So again make sure all this is correct. Are you using 3.3v or 5v arduino? What are the specs for the pcb 5v or 3.3v?

Of course it could also be a bad module that is faulty....

Thank you Skywatch for your suggestions. The battery shows 3.0v on the multimeter, so it seems like it survived. I had my doubts regarding this as well, so I used two 1.5v AA cells in a battery holder as a backup battery. However, the problem persists.

I'm using a CR2032, it's not Rechargeable, however I could replace it with LIR2032 and as you suggested a relevant battery holder, once the module exhibits some timekeeping capability with a connected battery. On the other hand, the module seems to store time with an electrolytic Capacitor.

It doesn't make any sense to me that it would work with the cap but not the cr2032 cell or the AA cells. Can't think of any other suggestions at the moment, sorry. I did have a faulty rtc, a few years back. It was probably a ds1307. It would not retain the time, even though ~3.2V was present at its Vbatt pin. I never thought to try a cap, but then why would I have?

I know what you mean about the size of the ds3231 modules sold for use with Arduino these days. You used to be able to get much more compact ones.

Edit: you can still get them. They are a little smaller than the usual design.s-l400 (5).jpg

Just spotted this one too. Not seen those before.
s-l400 (6).jpgs-l400 (7).jpg

s-l400 (5).jpg

s-l400 (6).jpg

s-l400 (7).jpg

PaulRB:
It doesn't make any sense to me that it would work with the cap but not the cr2032 cell or the AA cells. Can't think of any other suggestions at the moment, sorry. I did have a faulty rtc, a few years back. It was probably a ds1307. It would not retain the time, even though ~3.2V was present at its Vbatt pin. I never thought to try a cap, but then why would I have?

I know what you mean about the size of the ds3231 modules sold for use with Arduino these days. You used to be able to get much more compact ones.

Indeed! The newer RTC modules are even larger than Arduino Mini PRO. The "DS3231 for Pi" seem an ideal form factor, that's the reason I opted for these.

Unfortunately, only the most common modules are locally available here and shipping from overseas invites extended charges and taxes so it the price itself dwarfs any other associated advantage.

As with the module itself, the problem is rather perplexing as the behaviour doesn't coincide with any documented aspect of the device. I'm literally out of options here. I would give another try with a 5v supercapacitor charged at 3.3v. There is a post related to that, though it's not recommended.

Either I'm missing something like some extra parameters that need to be set.

the RTC does not retain time.

Can you please clarify the problem statement for me.

Does this mean that the time value stored in the storage registers reverts to 0's?
Does this mean that the time values are not updated from the time when the device switched to battery power?

cattledog:
Can you please clarify the problem statement for me.

Does this mean that the time value stored in the storage registers reverts to 0's?
Does this mean that the time values are not updated from the time when the device switched to battery power?

Sure! The RTC upon resetting Arduino or removing power to the RTC reverts to 1/1/2000. So when the DS3231 library code runs again, it indicates that the RTC had lost power and sets it to current date and time. This behaviour occours when there is a non-rechargeable 3v battery attached to the module.

Update: I disconnected the module off the main power line and attached a 5.5v 1F supercapacitor charged at 3.3 volts to the backup power source. It's been about ten hours and it's internal Clock has been ticking since. The voltage has dropped to 2.9v. So it seems like these RTC modules function only with a rechargeable power source for time backup.

So it seems like these RTC modules function only with a rechargeable power source for time backup.

The device should function without a backup power source if you follow the data sheet instructions for the VBAT pin: "If VBAT is not used, connect to ground."

Don

floresta:
The device should function without a backup power source if you follow the data sheet instructions for the VBAT pin: "If VBAT is not used, connect to ground."

Don

Please read the discussion carefully. The device is working fine. It's not retaining time with a 3v CR2302 and the datasheet is not helping. If the module doesn't retain time, it does not serve its purpose.

I can see why you have come to that theory. But I'm having difficulty believing that the chip would have been designed like that. The simplest answer is usually the right one, and the chip would have to be quite clever to be able to distinguish rechargeable from non-rechargeable. It would only be able to tell that the battery is non-rechargeable when external power is connected (and even then, it would be quite difficult to distinguish a fully-charged rechargeable from a non-rechargeable). Once external power is gone, it would have to remember that the battery was non-rechargeable, and refuse to use it, which would be a crazy design decision for an rtc chip! But I don't have another theory to explain what you have observed...

PaulRB:
I can see why you have come to that theory. But I'm having difficulty believing that the chip would have been designed like that. The simplest answer is usually the right one, and the chip would have to be quite clever to be able to distinguish rechargeable from non-rechargeable. It would only be able to tell that the battery is non-rechargeable when external power is connected (and even then, it would be quite difficult to distinguish a fully-charged rechargeable from a non-rechargeable). Once external power is gone, it would have to remember that the battery was non-rechargeable, and refuse to use it, which would be a crazy design decision for an rtc chip! But I don't have another theory to explain what you have observed...

I understand and your hypothesis is certainly rational given the financial inputs that dictate simplicity of electronics design. However implausible it may appear, I have tried the module with everything 3v non-rechargeable and the effect is same. That's the reason I sought advice from people with more experience. These "DS3231 for Pi" RTCs fall under the margins of such modules. Usually the standard larger form factor modules seem more popular and they simply work, albeit their size may pose issues if space is a constraint. Moreover its not the case with one module, all three, now work well with a 1F capacitor.

Update: I disconnected the module off the main power line and attached a 5.5v 1F supercapacitor charged at 3.3 volts to the backup power source.

Since you are using the supercapacitor as the backup power source I assume that you actually connected it to VBAT. If you did things in the order mentioned then that could explain why your device isn't working as expected. There are at least two applicable data sheet sections for you to consider.

When you disconnect VCC first and subsequently connect the charged capacitor to VBAT you are essentially using the VBAT input as the primary battery source. The 'Pin Description' for VBAT states: "When using the device with the VBAT input as the primary power source, this pin should be decoupled using a 0.1μF to 1.0μF low-leakage capacitor."

The 'Power Control' section also had the following statement: "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. " . . . "Once the oscillator is running, it continues to run as long as a valid power source is available (VCC or VBAT), . . .".

Don

Just to throw something else in here.....

Maybe the module is not working to spec anyway. Get a refund right away.

I once ordered 10 from ebay, they arrived from China.

2 didn't work at all.
1 had a different understanding of time to most of the rest of the World.

7 worked well.

Since they were cheap (and had rechargeable batteries as well) I didn't complain to the seller. These days, I would get right back in touch as I have had too much junk/fake/dangerous items from China this year (and a lot of orders that didn't arrive at all)......

floresta:
Since you are using the supercapacitor as the backup power source I assume that you actually connected it to VBAT. If you did things in the order mentioned then that could explain why your device isn't working as expected. There are at least two applicable data sheet sections for you to consider.

When you disconnect VCC first and subsequently connect the charged capacitor to VBAT you are essentially using the VBAT input as the primary battery source. The 'Pin Description' for VBAT states: "When using the device with the VBAT input as the primary power source, this pin should be decoupled using a 0.1μF to 1.0μF low-leakage capacitor."

The 'Power Control' section also had the following statement: "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. " . . . "Once the oscillator is running, it continues to run as long as a valid power source is available (VCC or VBAT), . . .".

Don

So, that would imply that the module lacks the necessary passive components required for the Vbatt function to perform?

skywatch:
Just to throw something else in here.....

Maybe the module is not working to spec anyway. Get a refund right away.

I once ordered 10 from ebay, they arrived from China.

2 didn't work at all.
1 had a different understanding of time to most of the rest of the World.

7 worked well.

Since they were cheap (and had rechargeable batteries as well) I didn't complain to the seller. These days, I would get right back in touch as I have had too much junk/fake/dangerous items from China this year (and a lot of orders that didn't arrive at all)......

I can understand that cheap shipments from China can have implied quality tradeoffs. As for these "DS3231 for Pi" modules, I have already implemented one of them for a wireless weather station. I also tied a GPIO pin via a Diode to a 200ohm resistor to the positive terminal of the supercapacitor. The pin is held hight for a few seconds once a week to keep the Capacitor charged up. I'm uncertain if this could have contrary results on the system or Arduino in the long run, but this seems to work. Please excuse me for this, electronics is not my domain.

So, that would imply that the module lacks the necessary passive components required for the Vbatt function to perform?

I would say that the module has the necessary components to perform as expected when used in the typical manner, with VCC as the primary source and VBAT as a backup but it may not have the necessary components to run with VBAT as the primary source.

In addition it appears that you cannot expect it to run if you merely connect power to VBAT.

Don

As a test you could try running it from a 5v battery and see if that makes a difference?

floresta:
I would say that the module has the necessary components to perform as expected when used in the typical manner, with VCC as the primary source and VBAT as a backup but it may not have the necessary components to run with VBAT as the primary source.

In addition it appears that you cannot expect it to run if you merely connect power to VBAT.

Don

Please, can you elaborate on the technicalities of the process involved? What I need to do to make it retain time once the primary power is lost. How should I connect the battery. Here I need to emphasise that the module retains time when a Capacitor charged at 3v is attached to Vbatt.