Not able to set time and get updated time in RTC- DS32321

I am new to coding and Arduino.

I am trying to display time from RTC DS32321 on TM1637Display using ATtiny85.

I am facing two issues.

  1. I am not able to set time to RTC using below code (referred API : DS3231/Time-Set.md at master · NorthernWidget/DS3231 · GitHub ) .

#include <TM1637Display.h>
#include <TinyWireM.h>
#include <DS3231.h>

#define CLK 1
#define DIO 3

DS3231 rtc;
TM1637Display display = TM1637Display(CLK, DIO);

bool h12Flag;
bool pmFlag;

void setup() {

 Wire.begin();  

// Begin serial communication
Serial.begin(9600);
// Set the display brightness (0-7)
display.setBrightness(7);

byte h = 21;
byte m = 28;
rtc.setHour(h);
rtc.setMinute(m);

}

void loop() {
// put your main code here, to run repeatedly: //

int displayTime= rtc.getHour(h12Flag,pmFlag)+rtc.getMinute();
 Serial.println(displayTime);
 display.showNumberDecEx(displayTime,0b11100000,true); 

}

  1. When I disconnect the power from ATtiny85 to check if RTC is working when mains power drops RTC should update the Time ( coin-cell shows voltage as a back-up) but RTC doesn't show correct time after getting the Mains power. It starts again from where it left off.

Which DS3231 RTC module are you using?
Which TM1637 module are you using?
How have you connected them to the TINY85?

If the RTC oscillator turns off when you switch off Vcc power, even though the coin cell is present, it probably means the /EOSC bit in the Control register is set. I believe that bit is cleared if you completely power down the RTC, including removing the coin cell, then power up again. At least that's what the datasheet says.

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