Smart Home Automation Forum
[Arduino source code for KC868-A32M]-01_DS3231_RTC - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20)
+--- Forum: KC868-A32M (https://www.kincony.com/forum/forumdisplay.php?fid=49)
+--- Thread: [Arduino source code for KC868-A32M]-01_DS3231_RTC (/showthread.php?tid=2879)



[Arduino source code for KC868-A32M]-01_DS3231_RTC - KinCony Support - 05-06-2023

[Arduino source code for KC868-A32M]-01_DS3231_RTC
Code:
// KC868-A32M  RTC CODE DS3231

#include <Wire.h>
#include "RTClib.h"

#define SDA 4
#define SCL 5
RTC_DS3231 myRTC;

void setup () {
    Serial.begin(115200);
    Wire.begin(SDA,SCL);
    delay(500);
    myRTC.begin();
    myRTC.adjust(DateTime(F(__DATE__), F(__TIME__)));
}

void loop () {
     
    DateTime now = myRTC.now();
    Serial.printf("%02d/%02d/%02d  %02d:%02d:%02d\n",
                                          now.year(),
                                          now.month(),
                                          now.day(),
                                          now.hour(),
                                          now.minute(),
                                          now.second());
   delay(1000);
   

   
}