#include <Wire.h>
#include <RTClib.h>
RTC_DS3231 rtc; // Create an instance of the RTC DS3231
const int timezoneOffsetHours = 0; // Adjust this according to your timezone
const int timezoneOffsetMinutes = 30; // Adjust this according to your timezone
void setup() {
Wire.begin();
Serial.begin(9600);
if (!rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
if (rtc.lostPower()) {
Serial.println("RTC lost power, let's set the time!");
// Set the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
}
void loop() {
DateTime now = rtc.now();
// Adjust for timezone offset
now = now + TimeSpan(timezoneOffsetHours, timezoneOffsetMinutes, 0, 0);
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
delay(1000);
}