|
FabGL
ESP32 Display Controller and Graphics Library
|
DS3231 Real Time Clock driver. More...
#include <DS3231.h>
Public Member Functions | |
| bool | available () |
| Determines if DS3231 is reachable. More... | |
| void | begin (I2C *i2c) |
| Initializes DS3231 driver. More... | |
| void | clockEnabled (bool value) |
| Enables or disables DS3231 oscillator. More... | |
| DateTime const & | datetime () |
| Queries DS3231 for current date and time. More... | |
| bool | dateTimeValid () |
| Determines the validity of datetime. More... | |
| bool | setDateTime (DateTime const &value) |
| Sets current date and time. More... | |
| double | temperature () |
| Forces DS3231 to read current temperature. More... | |
DS3231 Real Time Clock driver.
Example:
fabgl::I2C I2C;
fabgl::DS3231 DS3231;
void setup() {
I2C.begin(GPIO_NUM_4, GPIO_NUM_15); // 4 = SDA, 15 = SCL (WARN: disconnect VGA connector!!)
DS3231.begin(&I2C);
auto dt = DS3231.datetime();
Serial.printf("%02d/%02d/%d %02d:%02d:%02d\n", dt.dayOfMonth, dt.month, dt.year, dt.hours, dt.minutes, dt.seconds);
Serial.printf("temp = %0.3f C\n", DS3231.temperature());
}