Can't get DS3231 to work

I'm trying to set time on DS3231 and it works as long as arduino nano is connected to PC (power). As soon as I disconnect it and reconnect it, the time goes back to 1.1.2000.
I have tried both Rinky Dink library with the given example and the RTClib library. I tried with two different batteries and checked that the batteries do indeed work. I have also tried other similar guides but nothing seems to work.
Setting up time (by uncommenting, uploading and again commenting) works just fine, but it seems like the RTC doesn't receive power from the battery?

Hardware: DS3231, arduino nano

Wiring: VCC -> Arduino 5V
GND -> Arduino GND
SDA -> Arduino A4
SCL -> Arduino A5

#include <DS3231.h>

// Init the DS3231 using the hardware interface
DS3231  rtc(SDA, SCL);

void setup()
{
  // Setup Serial connection
  Serial.begin(9600);
  // Uncomment the next line if you are using an Arduino Leonardo
  //while (!Serial) {}
  
  // Initialize the rtc object
  rtc.begin();
  
  // The following lines can be uncommented to set the date and time
 // rtc.setDOW(SATURDAY);     // Set Day-of-Week to SUNDAY
 // rtc.setTime(9, 29, 40);     // Set the time to 12:00:00 (24hr format)
 // rtc.setDate(20, 2, 2021);   // Set the date to January 1st, 2014
}

void loop()
{
  // Send Day-of-Week
  Serial.print(rtc.getDOWStr());
  Serial.print(" ");
  
  // Send date
  Serial.print(rtc.getDateStr());
  Serial.print(" -- ");

  // Send time
  Serial.println(rtc.getTimeStr());
  
  // Wait one second before repeating :)
  delay (1000);
}

It does look like a hardware problem , I take you are checking the batteries with a dvm ? I think I’d try and find a schematic for the board and trace where the battery connections go .
It might be worth googling the problem in case it appears elsewhere on this forum or others .

A typical problem appears that the battery holder doesn’t connect very well . There is a pin on the 3231 that connects to that - check voltage is there .

It seems to be a hardware problem yes. With my basic knowledge of electronics this is what I have figured out so far.
Picture of the RTC back:

If I jump wire the way it is shown in the picture (red line) than the power LED (green circle) turns on. I'm guessing the component that looks like it was fried (orange circle) i a resistor? I can't seem to figure that out from schematics. If it is a resistor I might be able to replace, if it's something like a capacitor than I'll have to waif for another RTC module.

I'm guessing simply putting a wire the way it's shown in the picture would be a big no no.

Thanks for the help!

The modules are cheap ....

Schematic of similar :

Yea, I know. It's just the time it takes for these components to arrive. I buy stuff from aliexpress and it's usually a gamble. Sometimes I get what I ordered in 3 weeks sometimes in 3 months :smiley:

Anyways, thanks for the help!

I'm guessing there's a CR2032 battery holder. I have very bad experience trying to use a thinner one (2016 or 2025). Just no reliable contact.

Also do measure the battery voltage at the pins of the chip. Make sure it's all connected properly.

With that wire you have put 5V on the battery. Get rid of that module and get rid of the battery.
I will wait until you have put them away...

They are gone ? Okay. Buy a normal DS3231 module from a good seller: Adafruit DS3231 Precision RTC Breakout : ID 3013 : $17.50 : Adafruit Industries, Unique & fun DIY electronics and kits.

Suppose you did not get rid of that cheap module and it is not broken. Then there are ways to make those modules work:

  • When using them with a rechargeable battery, then they can be used with a 3.3V Arduino board and with 3.3V to the VCC pin. It is far from ideal and the DS3231 is probably counterfeit.
  • To use them with a 5V Arduino board, remove the diode from the module and use a normal battery (not a rechargeable battery). You still have a DS3231 that is probably counterfeit.
  • Or do as I did for a 5V Arduino board. Don't remove the diode, and solder a 5V supercap in the place of the battery. It should run a few hours without power. The DS3231 is still counterfeit.

I think that your DS3231 module is broken. The led should turn on as soon as you connect GND and VCC.

Why do you assume the DS3231 chip is counterfeit? I've bought lots of modules directly from China and have yet to run into any that are counterfeit. Or maybe the counterfeits that I got are so good they're fully indistinguishable from the original both in outlook and functionality, in which case there's still no problem.

wvmarle:
Why do you assume the DS3231 chip is counterfeit?

I remember reading about the DS3231 and that its current use was more than in the datasheet and its price lower than its costs. Either counterfeit or factory rejects, it is not the real thing.

There are many pages about 'fake' or 'counterfeit' DS3231, I don't know who did a good investigation.
I think it is more likely to be factory rejects. My fake DS3231 is running just fine by the way.

At mouser.com, the DS3231 costs about 5 euros, or 3.42 euros for 2500 pieces of a certain type.
At AliExpress, a DS3231 with pcb board, a battery holder and other components costs between 1 euro and 3 euros. You do the math :wink:

Koepel:
At mouser.com, the DS3231 costs about 5 euros, or 3.42 euros for 2500 pieces of a certain type.
At AliExpress, a DS3231 with pcb board, a battery holder and other components costs between 1 euro and 3 euros. You do the math :wink:

I know - shockingly expensive, same on RS Components.
The cheap Aliexpress ones are definitely not all factory rejects, the availability of them is just far too good. Rejects shouldn't be more than a few % of production, if that much, and many factories will go to great lengths to prevent rejects ending up on the open market as it undermines their own product.
Yet the cheap ones that are available appear to work just the same, with the exact same high quality screen print on the chips (that's often a giveaway when talking about counterfeits, and even China has regulations preventing factories from making too exact copies).

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.