Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RTC stop working with button cell
#3
#include <Wire.h>
#include <RTClib.h>

RTC_DS1307 rtc;

void setup() {
Serial.begin(9600);
Wire.begin(4,15); //SDA is GPIO4 SCL is GPIO15
rtc.begin();

// Set initial time

// rtc.adjust(DateTime(2023, 7, 21, 9, 53, 50));

// You only need to set the initial time once. After setting the initial time, you should comment out the
//above line when uploading the code again to avoid resetting the time every time you start.
}

void loop() {
DateTime now = rtc.now();

// Print the date and time
Serial.print("The time is: ");
Serial.print(now.year(), DEC);
Serial.print("-");
printDigits(now.month());
Serial.print("-");
printDigits(now.day());
Serial.print("-");
printDigits(now.hour());
Serial.print("-");
printDigits(now.minute());
Serial.print("-");
printDigits(now.second());
Serial.println();

delay(1000);
}

void printDigits(int digits) {
if (digits < 10) {
Serial.print("0");
}
Serial.print(digits);
}
Reply


Messages In This Thread
RTC stop working with button cell - by jmartin - 07-20-2023, 05:30 PM
RE: RTC stop working with button cell - by KinCony Support - 07-21-2023, 02:01 AM
RE: RTC stop working with button cell - by admin - 09-28-2023, 05:06 AM
RE: RTC stop working with button cell - by admin - 09-28-2023, 05:31 AM
RE: RTC stop working with button cell - by admin - 10-02-2023, 08:24 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)