### Basic GyverDS3231Min Usage Example Source: https://github.com/gyverlibs/gyverds3231/blob/main/README.md Demonstrates initializing the GyverDS3231Min library, setting the time zone, checking RTC status (OK, Reset), setting build time if reset, and continuously printing the current time to the serial monitor. This example showcases fundamental interactions with the DS3231 RTC chip. ```cpp #include GyverDS3231Min rtc; void setup() { Serial.begin(115200); Serial.println("start"); setStampZone(3); // часовой пояс Wire.begin(); rtc.begin(); Serial.print("OK: "); Serial.println(rtc.isOK()); Serial.print("Reset: "); Serial.println(rtc.isReset()); // был сброс питания RTC, время некорректное if (rtc.isReset()) { rtc.setBuildTime(); // установить время компиляции прошивки // rtc.setTime(2025, 1, 30, 12, 45, 0); // установить время вручную } // вывести в Datime Datime dt = rtc.getTime(); Serial.println(dt.year); Serial.println(dt.month); Serial.println(dt.day); Serial.println(dt.hour); Serial.println(dt.minute); Serial.println(dt.second); } void loop() { // прочитать и вывести время строкой Serial.println(rtc.getTime().toString()); delay(1000); } ``` -------------------------------- ### Arduino Gyverds3231 Library Basic Usage Example Source: https://github.com/gyverlibs/gyverds3231/blob/main/README_EN.md Demonstrates basic initialization and usage of the Gyverds3231 library on an Arduino platform. It shows how to begin the RTC module, set time manually or from compilation time, and continuously read and display time and date in the loop. ```CPP #include Gyverds3231 ds; VOID setup () { setstampzone (3);// specify a time zone if the program needs a real unix // if not needed, you can not specify (remain 0) Serial.Begin (115200); Wire.begin (); // Launch and synchronize time, if possible DS.Begin (); // Launch on another driver i2c // DS.Begin (& Customwire); // OR // If the start is unsuccessful (for example, there was a power supply RTC) // set time equal to compilation time // if (! ds.begin ()) ds.Setbuildtime (); // Time installation manually // ds.Settime (123456789ul);// unix // ds.Settime (Datime (2024, 7, 27, 17, 6, 30));// y.m.d h: m: s // Datime DT; // dt.second = 34; // ... set the date and time ... // and send to RTC // ds.Settime (DT); } VOID loop () { // call a ticker in look // The ticker will also return True every second, which is convenient for comparing time if (ds.tick ()) { Serial.println (ds.tostring ());// Date and time withdrawal Serial.println (ds.datetostosting ());// Date of dates by lineCranberry // can be compared directly with UNIX if (ds >= 12345) {} if (ds == 123456) {} ds.getunix ();// Get Unix seconds // Unix Parsing on date and time DS.Second ();// seconds ds.minute ();// minutes and so on // more efficiently use Datime Parser Datime DT (DS);// ds itself converts into Datime dt.year; DT.MONTH; dt.day; DT.Hour; dt.minute; DT.Second; DT.Weekday; dt.yearday; // for automation inside the day, it is convenient to use // seconds from the beginning of the day, Dayseconds () DS.DaySeconds (); // For convenience, there is also a class Dayseconds class that allows you to set time inside the day Dayseconds DSEC (5, 10, 0);// 5 hours, 10 minutes, 0 seconds // gyverds3231 can be compared directly to Dayseconds if (ds == dsec) {} } } ``` -------------------------------- ### Initialize and Use GyverDS3231 RTC Source: https://github.com/gyverlibs/gyverds3231/blob/main/README.md This snippet demonstrates how to initialize the GyverDS3231 library for an Arduino project, set the time (either from build time or manually), check the RTC status, and continuously read and compare time values. It covers basic setup, handling power resets, and accessing time components through different methods. ```cpp #include #include GyverDS3231 rtc; void setup() { Serial.begin(115200); Serial.println("start"); setStampZone(3); // часовой пояс Wire.begin(); rtc.begin(); Serial.print("OK: "); Serial.println(rtc.isOK()); Serial.print("Reset: "); Serial.println(rtc.isReset()); // был сброс питания RTC, время некорректное if (rtc.isReset()) { rtc.setBuildTime(); // установить время компиляции прошивки // rtc.setTime(2025, 1, 30, 12, 45, 0); // установить время вручную } } void loop() { // тикер вернёт true каждую секунду в 0 мс секунды, если время синхронизировано if (rtc.tick()) { // вывод даты и времени строкой Serial.print(rtc.toString()); // rtc.timeToString(), rtc.dateToString() Serial.print(':'); Serial.println(rtc.ms()); // + миллисекунды текущей секунды. Внутри tick всегда равно 0 // вывод в Datime Datime dt = rtc; // или Datime dt(rtc) dt.year; dt.second; dt.hour; dt.weekDay; dt.yearDay; // ... и прочие методы и переменные Datime // чтение напрямую, медленнее чем вывод в Datime rtc.second(); rtc.minute(); rtc.year(); // ... и прочие методы StampConvert // сравнение rtc == DaySeconds(12, 35, 0); // сравнение с DaySeconds (время равно 12:35:00) rtc == 1738237474; // сравнение с unix rtc == Datime(2025, 1, 30, 14, 14, 30); // сравнение с Datime } if (rtc.newSecond()) { // новую секунду можно поймать и здесь } } ``` -------------------------------- ### Gyverds3231 Class API Reference Source: https://github.com/gyverlibs/gyverds3231/blob/main/README_EN.md Documents the public methods and constructor of the Gyverds3231 library for interacting with the DS3231 RTC module. It includes methods for initialization, time synchronization, setting time, reading temperature, and managing calibration offset. ```APIDOC Gyverds3231: __init__(Syncprd: Uint16_t = 60 * 60) Syncprd: Synchronization period in seconds (default 1 hour) Begin(Wire: Twowire* = &Wire, Addr: Uint8_t = 0x68) -> Bool Wire: Optional I2C driver (defaults to &Wire) Addr: I2C address (defaults to 0x68) Returns: True on success updatatenow() -> Bool Returns: True on success, False on error or after RTC power reset Gettime() -> Datime Returns: Current time from RTC setbuildtime() -> Bool Returns: True on success settime(DT: Datime) -> Bool DT: Datime object or various string/unix formats ("hh:mm:ss", "yyyy-mm-dd", "yyyy-mm-ddThh:mm:ss", unix timestamp, or Datime object) Returns: True on success Tick() -> Bool Returns: True every second if time is synchronized gettemp() -> Float Returns: Chip temperature Gettempint() -> int Returns: Chip temperature (integer) getoffset() -> int8_t Returns: Calibration displacement (value * 0.1PPM) Setoffset(Offseet: Int8_T) -> Bool Offseet: Calibration displacement (value * 0.1PPM) Returns: True on success ``` -------------------------------- ### GyverDS3231 Library Methods and Functions Source: https://github.com/gyverlibs/gyverds3231/blob/main/keywords.txt Lists the public methods and functions available in the GyverDS3231 library, categorized as KEYWORD2 for syntax highlighting. ```APIDOC begin: Method (KEYWORD2) updateNow: Method (KEYWORD2) getTime: Method (KEYWORD2) setBuildTime: Method (KEYWORD2) setTime: Method (KEYWORD2) tick: Method (KEYWORD2) getTemp: Method (KEYWORD2) getTempInt: Method (KEYWORD2) getOffset: Method (KEYWORD2) setOffset: Method (KEYWORD2) ``` -------------------------------- ### GyverDS3231Min Class API Reference Source: https://github.com/gyverlibs/gyverds3231/blob/main/README.md API documentation for the GyverDS3231Min class, which provides direct interaction with the DS3231 RTC chip for time reading, setting, and temperature retrieval. It allows for initialization, status checks, time manipulation (including Unix time), temperature acquisition, and calibration offset management. ```APIDOC GyverDS3231Min: begin(wire: TwoWire* = &Wire, addr: uint8_t = 0x68): bool Description: Initializes the RTC. Can specify a different Wire driver and I2C address. Returns true on success. isOK(): bool Description: Checks if the RTC is working correctly. isReset(): bool Description: Checks if there was a power reset. getTime(): Datime Description: Reads the current time from RTC. setTime(year: uint16_t, month: uint8_t, day: uint8_t, hour: uint8_t, minute: uint8_t, second: uint8_t): bool Description: Sets the RTC time using individual date and time components. setTime(dt: Datime): bool Description: Sets the RTC time using a Datime object or string formats like "hh:mm:ss", "yyyy-mm-dd", "yyyy-mm-ddThh:mm:ss", or Unix timestamp. setBuildTime(): bool Description: Sets the RTC time to the firmware compilation time. getTemp(): float Description: Gets the chip temperature as a float. getTempInt(): int Description: Gets the chip temperature as an integer. getOffset(): int8_t Description: Gets the calibration offset (value * 0.1ppm). setOffset(offset: int8_t): bool Description: Sets the calibration offset (value * 0.1ppm). setUnix(unix: uint32_t): void Description: Sets the RTC Unix time (will be converted to local time). getUnix(): uint32_t Description: Gets the RTC Unix time (GMT+0). ``` -------------------------------- ### GyverDS3231 Class API Reference Source: https://github.com/gyverlibs/gyverds3231/blob/main/README.md API documentation for the GyverDS3231 class, which extends GyverDS3231Min and StampKeeper. This class manages time using millis() and synchronizes with the RTC via a timer, providing methods for setting synchronization periods, initializing, forcing updates, and a loop ticker. ```APIDOC GyverDS3231: GyverDS3231(syncPrd: uint16_t = 60 * 60) Description: Constructor. Sets the synchronization period in seconds. setPeriod(syncPrd: uint16_t): void Description: Sets the synchronization period in seconds. begin(wire: TwoWire* = &Wire, addr: uint8_t = 0x68): bool Description: Initializes and synchronizes. Can specify a different Wire driver and I2C address. Returns true on success. updateNow(): bool Description: Synchronizes time with RTC. Returns true on success, false on bus error or after RTC power reset. tick(): bool Description: Ticker function, call in loop. Returns true every second if time is synchronized. ``` -------------------------------- ### GyverDS3231 Library Datatypes Source: https://github.com/gyverlibs/gyverds3231/blob/main/keywords.txt Defines the primary datatype 'GyverDS3231' used within the library, categorized as KEYWORD1 for syntax highlighting. ```APIDOC GyverDS3231: Datatype (KEYWORD1) ``` -------------------------------- ### GyverDS3231 Library Constants Category Source: https://github.com/gyverlibs/gyverds3231/blob/main/keywords.txt Indicates the category for constants (LITERAL1) within the GyverDS3231 library's syntax map. Specific constant values are not provided in this document. ```APIDOC Constants: LITERAL1 category ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.