DS1302 Odd Behavior

I have 2 of the VMA301 RTC boards and they are both acting weird. These have the DS1302 chip on them. I did have them working at one point and I didn’t make any code changes. I tried the example code below the serial output and got the same results. I hope someone can help me figure it out because it’s driving me a little nuts! LOL

Here’s what I get from my Serial monitoring. I hope this helps:

16:07:51.942 -> getDOWStr: 000:00:00
16:07:51.942 -> getDateStr: 00/00/2000
16:07:51.942 -> getTimeStr: 00:00:00

16:07:53.981 -> getDOWStr: 000:00:00
16:07:53.981 -> getDateStr: 00/00/2000
16:07:53.981 -> getTimeStr: 00:00:00

16:07:56.038 -> getDOWStr: 000:00:00
16:07:56.038 -> getDateStr: 41/01/2004
16:07:56.038 -> getTimeStr: 00:00:00

16:07:58.082 -> getDOWStr: 100:00:00
16:07:58.082 -> getDateStr: 00/00/2000
16:07:58.082 -> getTimeStr: 00:00:00

16:08:00.130 -> getDOWStr: 000:00:00
16:08:00.130 -> getDateStr: 00/00/2000
16:08:00.130 -> getTimeStr: 00:00:00

16:08:02.184 -> getDOWStr: 000:00:00
16:08:02.184 -> getDateStr: 00/00/2000
16:08:02.184 -> getTimeStr: 00:00:00

16:08:04.216 -> getDOWStr: 000:00:00
16:08:04.216 -> getDateStr: 00/00/2000
16:08:04.250 -> getTimeStr: 00:00:00

16:08:06.286 -> getDOWStr: 000:00:00
16:08:06.286 -> getDateStr: 00/00/2000
16:08:06.286 -> getTimeStr: 00:00:00

16:08:08.334 -> getDOWStr: 000:00:00
16:08:08.334 -> getDateStr: 00/00/2000
16:08:08.334 -> getTimeStr: 00:00:00

16:08:10.367 -> getDOWStr: 000:00:00
16:08:10.367 -> getDateStr: 00/00/2000
16:08:10.367 -> getTimeStr: 00:00:00

16:08:12.426 -> getDOWStr: 000:00:00
16:08:12.426 -> getDateStr: 00/00/2000
16:08:12.426 -> getTimeStr: 00:00:00

16:08:14.474 -> getDOWStr: 000:00:00
16:08:14.474 -> getDateStr: 00/00/2000
16:08:14.474 -> getTimeStr: 00:00:00

16:08:16.515 -> getDOWStr: 000:00:00
16:08:16.515 -> getDateStr: 00/00/2000
16:08:16.515 -> getTimeStr: 00:00:00

16:08:18.576 -> getDOWStr: Tuesday
16:08:18.576 -> getDateStr: 03/02/2009
16:08:18.576 -> getTimeStr: 01:00:51

16:08:20.599 -> getDOWStr: Tuesday
16:08:20.633 -> getDateStr: 07/02/2009
16:08:20.633 -> getTimeStr: 01:00:19

16:08:22.646 -> getDOWStr: Tuesday
16:08:22.683 -> getDateStr: 07/02/2009
16:08:22.683 -> getTimeStr: 01:00:01

16:08:24.697 -> getDOWStr: Tuesday
16:08:24.731 -> getDateStr: 03/02/2009
16:08:24.731 -> getTimeStr: 01:00:03

16:08:26.771 -> getDOWStr: Saturday
16:08:26.771 -> getDateStr: 07/06/2019
16:08:26.771 -> getTimeStr: 15:44:45

16:08:28.810 -> getDOWStr: 715:44:45
16:08:28.810 -> getDateStr: 85/85/2165
16:08:28.810 -> getTimeStr: 27:85:85
// DS1302_LCD 
// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// A quick demo of how to use my DS1302-library to make a quick
// clock using a DS1302 and a 16x2 LCD.
//
// I assume you know how to connect the DS1302 and LCD.
// DS1302:  CE pin    -> Arduino Digital 2
//          I/O pin   -> Arduino Digital 3
//          SCLK pin  -> Arduino Digital 4
// LCD:     DB7       -> Arduino Digital 6
//          DB6       -> Arduino Digital 7
//          DB5       -> Arduino Digital 8
//          DB4       -> Arduino Digital 9
//          E         -> Arduino Digital 10
//          RS        -> Arduino Digital 11

#include <LiquidCrystal.h>
#include <DS1302.h>

// Init the DS1302
DS1302 rtc(32, 33, 34);

// Init the LCD
LiquidCrystal lcd(22, 23, 24, 25, 26, 27, 28);

void setup()
{
  // Set the clock to run-mode, and disable the write protection
  rtc.halt(false);
  rtc.writeProtect(false);
  
  // Setup LCD to 16x2 characters
  lcd.begin(20, 4);

  // The following lines can be commented out to use the values already stored in the DS1302
  rtc.setDOW(FRIDAY);        // Set Day-of-Week to FRIDAY
  rtc.setTime(12, 0, 0);     // Set the time to 12:00:00 (24hr format)
  rtc.setDate(6, 8, 2010);   // Set the date to August 6th, 2010
}

void loop()
{
  // Display time centered on the upper line
  lcd.setCursor(4, 0);
  lcd.print(rtc.getTimeStr());
  
  // Display abbreviated Day-of-Week in the lower left corner
  lcd.setCursor(0, 1);
  lcd.print(rtc.getDOWStr(FORMAT_SHORT));
  
  // Display date in the lower right corner
  lcd.setCursor(6, 1);
  lcd.print(rtc.getDateStr());

  // Wait one second before repeating :)
  delay (1000);
}

Are you using a Arduino Mega 2560 board ?
Can you buy a DS3231 module ?

Most cheap DS3231 modules are for a rechargeable battery. But the circuit will over-charge the battery. The circuit is just a diode and resistor. You can stop the over-charging by removing the diode or the resistor from the module and use a normal battery. Others keep the resistor and diode and use a capacitor instead of a battery.

Avoid the DS1302. If the crystal is cheap it will never work reliable. There are libraries that do specific timings and special sequences for the three signals, trying to keep it working. The DS1302 is odd by itself.

I've not had any issues with the DS1302, had it reliably running for months/years in clocks.

Haven't used that module though, just the circuit from the datasheet. Check the button cell isn't
flat, check the supply is 5V (the chip doesn't work at 3.3V). Check the module has decoupling and
groundplane under the crystal as per datasheet.

You are supposed to post code in code tags so its easy to look at - can you edit your posting to do this?

Koepel:
Are you using a Arduino Mega 2560 board ?
Can you buy a DS3231 module ?

Most cheap DS3231 modules are for a rechargeable battery. But the circuit will over-charge the battery. The circuit is just a diode and resistor. You can stop the over-charging by removing the diode or the resistor from the module and use a normal battery. Others keep the resistor and diode and use a capacitor instead of a battery.

Avoid the DS1302. If the crystal is cheap it will never work reliable. There are libraries that do specific timings and special sequences for the three signals, trying to keep it working. The DS1302 is odd by itself.

Thanks. I was seeing the same complaints from others about this chip. I'm going to get the 3231 chip today. Thanks!

MarkT:
I've not had any issues with the DS1302, had it reliably running for months/years in clocks.

Haven't used that module though, just the circuit from the datasheet. Check the button cell isn't
flat, check the supply is 5V (the chip doesn't work at 3.3V). Check the module has decoupling and
groundplane under the crystal as per datasheet.

You are supposed to post code in code tags so its easy to look at - can you edit your posting to do this?

I edited my post, sorry about that.

I'm sure my wiring is correct and it is getting 5v and the battery is at 3.2v. I'm going to return this board and get a DS3231 chip to put on my breadboard.

Ds3231 is only available in SMD, not DIP.
[url]https://www.digikey.com/products/en/integrated-circuits-ics/clock-timing-real-time-clocks/690?k=ds3231[/url]

(forum adds some extra characters at the start of the link, I haven't figured out how to stop that)