25 #include <Adafruit_I2CDevice.h> 31 #define SECONDS_PER_DAY 86400L 32 #define SECONDS_FROM_1970_TO_2000 \ 39 DS1307_SquareWave1HZ = 0x10,
40 DS1307_SquareWave4kHz = 0x11,
41 DS1307_SquareWave8kHz = 0x12,
42 DS1307_SquareWave32kHz = 0x13
147 uint8_t min = 0, uint8_t sec = 0);
149 DateTime(
const char *date,
const char *time);
150 DateTime(
const __FlashStringHelper *date,
const __FlashStringHelper *time);
169 uint8_t
day()
const {
return d; }
181 uint8_t
isPM()
const {
return hh >= 12; }
278 TimeSpan(int16_t days, int8_t hours, int8_t minutes, int8_t seconds);
286 int16_t
days()
const {
return _seconds / 86400L; }
293 int8_t
hours()
const {
return _seconds / 3600 % 24; }
300 int8_t
minutes()
const {
return _seconds / 60 % 60; }
307 int8_t
seconds()
const {
return _seconds % 60; }
334 static uint8_t
bcd2bin(uint8_t val) {
return val - 6 * (val >> 4); }
340 static uint8_t
bin2bcd(uint8_t val) {
return val + 6 * (val / 10); }
341 Adafruit_I2CDevice *i2c_dev = NULL;
342 uint8_t read_register(uint8_t reg);
343 void write_register(uint8_t reg, uint8_t val);
353 bool begin(TwoWire *wireInstance = &Wire);
355 uint8_t isrunning(
void);
359 uint8_t readnvram(uint8_t address);
360 void readnvram(uint8_t *buf, uint8_t size, uint8_t address);
361 void writenvram(uint8_t address, uint8_t data);
362 void writenvram(uint8_t address,
const uint8_t *buf, uint8_t size);
372 bool begin(TwoWire *wireInstance = &Wire);
374 bool lostPower(
void);
384 void disableAlarm(uint8_t alarm_num);
385 void clearAlarm(uint8_t alarm_num);
386 bool alarmFired(uint8_t alarm_num);
387 void enable32K(
void);
388 void disable32K(
void);
389 bool isEnabled32K(
void);
390 float getTemperature();
408 bool begin(TwoWire *wireInstance = &Wire);
410 bool lostPower(
void);
411 bool initialized(
void);
418 void enableSecondTimer(
void);
419 void disableSecondTimer(
void);
421 uint8_t lowPulseWidth);
423 void disableCountdownTimer(
void);
424 void deconfigureAllTimers(
void);
435 bool begin(TwoWire *wireInstance = &Wire);
436 bool lostPower(
void);
498 void adjustDrift(
int ppm);
506 uint32_t microsPerSecond = 1000000;
char * toString(char *buffer) const
Writes the DateTime as a string in a user-defined format.
Definition: RTClib.cpp:441
DateTime(uint32_t t=SECONDS_FROM_1970_TO_2000)
Constructor from Unix time.
Definition: RTClib.cpp:161
bool operator<(const DateTime &right) const
Test if one DateTime is less (earlier) than another.
Definition: RTClib.cpp:647
bool operator<=(const DateTime &right) const
Test if one DateTime is less (earlier) than or equal to another.
Definition: RTClib.h:237
uint8_t ss
Seconds 0-59.
Definition: RTClib.h:267
Pcf8523OffsetMode
Definition: RTClib.h:113
timestampOpt
Definition: RTClib.h:205
RTC using the internal micros() clock, has to be initialized before use. Unlike RTC_Millis, this can be tuned in order to compensate for the natural drift of the system clock. Note that now() has to be called more frequently than the micros() rollover period, which is approximately 71.6 minutes.
Definition: RTClib.h:490
uint8_t d
Day 1-31.
Definition: RTClib.h:264
Simple general-purpose date/time class (no TZ / DST / leap seconds).
Definition: RTClib.h:143
uint8_t dayOfTheWeek() const
Return the day of the week.
Definition: RTClib.cpp:553
YYYY-MM-DD
Definition: RTClib.h:208
bool operator>=(const DateTime &right) const
Test if one DateTime is greater (later) than or equal to another.
Definition: RTClib.h:248
PCF8523TimerIntPulse
Definition: RTClib.h:101
bool isValid() const
Check whether this DateTime is valid.
Definition: RTClib.cpp:386
RTC based on the DS1307 chip connected via I2C and the Wire library.
Definition: RTClib.h:351
uint8_t day() const
Return the day of the month.
Definition: RTClib.h:169
uint8_t month() const
Return the month.
Definition: RTClib.h:164
Ds1307SqwPinMode
Definition: RTClib.h:36
uint32_t lastMillis
Definition: RTClib.h:478
uint8_t isPM() const
Return whether the time is PM.
Definition: RTClib.h:181
uint32_t lastUnix
Definition: RTClib.h:470
hh:mm:ss
Definition: RTClib.h:207
A generic I2C RTC base class. DO NOT USE DIRECTLY.
Definition: RTClib.h:326
#define SECONDS_FROM_1970_TO_2000
Unixtime for 2000-01-01 00:00:00, useful for initialization.
Definition: RTClib.h:32
String timestamp(timestampOpt opt=TIMESTAMP_FULL) const
Return a ISO 8601 timestamp as a String object.
Definition: RTClib.cpp:692
bool operator>(const DateTime &right) const
Test if one DateTime is greater (later) than another.
Definition: RTClib.h:226
int32_t _seconds
Actual TimeSpan value is stored as seconds.
Definition: RTClib.h:318
uint8_t second() const
Return the second.
Definition: RTClib.h:191
void begin(const DateTime &dt)
Start the RTC.
Definition: RTClib.h:496
PCF8523TimerClockFreq
Definition: RTClib.h:90
Pcf8563SqwPinMode
Definition: RTClib.h:119
uint8_t hour() const
Return the hour.
Definition: RTClib.h:174
RTC based on the PCF8523 chip connected via I2C and the Wire library.
Definition: RTClib.h:406
bool operator!=(const DateTime &right) const
Test if two DateTime objects are not equal.
Definition: RTClib.h:259
Pcf8523SqwPinMode
Definition: RTClib.h:78
YYYY-MM-DDThh:mm:ss
Definition: RTClib.h:206
static uint8_t dowToDS3231(uint8_t d)
Convert the day of the week to a representation suitable for storing in the DS3231: from 1 (Monday) t...
Definition: RTClib.h:398
int8_t minutes() const
Number of minutes in the TimeSpan This is not the total minutes, it includes days/hours e...
Definition: RTClib.h:300
static uint8_t bcd2bin(uint8_t val)
Convert a binary coded decimal value to binary. RTC stores time/date values as BCD.
Definition: RTClib.h:334
uint32_t unixtime(void) const
Return Unix time: seconds since 1 Jan 1970.
Definition: RTClib.cpp:568
uint32_t lastUnix
Definition: RTClib.h:512
void begin(const DateTime &dt)
Start the RTC.
Definition: RTClib.h:458
int8_t seconds() const
Number of seconds in the TimeSpan This is not the total seconds, it includes the days/hours/minutes e...
Definition: RTClib.h:307
uint32_t secondstime() const
Convert the DateTime to seconds since 1 Jan 2000.
Definition: RTClib.cpp:590
uint8_t m
Month 1-12.
Definition: RTClib.h:263
uint8_t twelveHour() const
Return the hour in 12-hour format.
Definition: RTClib.cpp:537
int8_t hours() const
Number of hours in the TimeSpan This is not the total hours, it includes the days e...
Definition: RTClib.h:293
Ds3231SqwPinMode
Definition: RTClib.h:46
int16_t days() const
Number of days in the TimeSpan e.g. 4.
Definition: RTClib.h:286
uint8_t minute() const
Return the minute.
Definition: RTClib.h:186
Timespan which can represent changes in time with seconds accuracy.
Definition: RTClib.h:275
uint16_t year() const
Return the year.
Definition: RTClib.h:159
DateTime operator+(const TimeSpan &span) const
Add a TimeSpan to the DateTime object.
Definition: RTClib.cpp:604
DateTime operator-(const TimeSpan &span) const
Subtract a TimeSpan from the DateTime object.
Definition: RTClib.cpp:615
uint32_t lastMicros
Definition: RTClib.h:516
uint8_t hh
Hours 0-23.
Definition: RTClib.h:265
RTC based on the DS3231 chip connected via I2C and the Wire library.
Definition: RTClib.h:370
static uint8_t bin2bcd(uint8_t val)
Convert a binary value to BCD format for the RTC registers.
Definition: RTClib.h:340
Ds3231Alarm1Mode
Definition: RTClib.h:55
bool operator==(const DateTime &right) const
Test if two DateTime objects are equal.
Definition: RTClib.cpp:671
Ds3231Alarm2Mode
Definition: RTClib.h:67
uint8_t mm
Minutes 0-59.
Definition: RTClib.h:266
uint8_t yOff
Year offset from 2000.
Definition: RTClib.h:262
RTC using the internal millis() clock, has to be initialized before use. NOTE: this is immune to mill...
Definition: RTClib.h:452
int32_t totalseconds() const
Total number of seconds in the TimeSpan, e.g. 358027.
Definition: RTClib.h:312
RTC based on the PCF8563 chip connected via I2C and the Wire library.
Definition: RTClib.h:433