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.
- 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);
}
- 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.