Skip to content

Instantly share code, notes, and snippets.

@vsizov
Last active July 2, 2025 13:25
Show Gist options
  • Save vsizov/645d08543609b5678ed2f1f6ec9ceb21 to your computer and use it in GitHub Desktop.
Save vsizov/645d08543609b5678ed2f1f6ec9ceb21 to your computer and use it in GitHub Desktop.

Revisions

  1. vsizov renamed this gist Jul 2, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. vsizov created this gist Jul 2, 2025.
    23 changes: 23 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    #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() {}