RTC DS1307 SETUP

This RTC does not show an accurate time. As time passes, the time indicated will be faster or slower than the actual time. For more/ best an accurate time, use RTC 3231, see on https://arduinoproyek.wordpress.com/2018/10/14/rtc3231-setup-2/

RTC1307

#include <Wire.h>

#include “RTClib.h”

RTC_DS1307 RTC;

void setup () {

Serial.begin(9600);

Wire.begin();

RTC.begin();

if (! RTC.isrunning()) {

Serial.println(“RTC is NOT running!”);

// following line sets the RTC to the date & time this sketch was compiled

RTC.adjust(DateTime(__DATE__, __TIME__));

}

}

void loop () {

DateTime now = RTC.now();

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);

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s