Last active
July 2, 2025 13:25
-
-
Save vsizov/645d08543609b5678ed2f1f6ec9ceb21 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <RTClib.h> | |
#define SDA1_PIN 21 | |
#define SCL1_PIN 22 | |
RTC_DS3231 rtc; | |
void setup() { | |
Wire1.begin(SDA1_PIN, SCL1_PIN); // Initialize Wire1 | |
if (!rtc.begin(&Wire1)) { // Pass Wire1 to RTC | |
Serial.println("Couldn't find RTC"); | |
while (1); | |
} | |
if (rtc.lostPower()) { | |
rtc.adjust(DateTime(2025, 7, 2, 14, 30, 0)); // Set to current time | |
} | |
Serial.begin(115200); | |
DateTime now = rtc.now(); | |
Serial.println(now.timestamp()); | |
} | |
void loop() {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment