Public Functions

  Name
  DS3231_Logger()
int begin(void )
int setTime(int Year, int Month, int Day, int Hour, int Min, int Sec)
void readTime()
Read the clock’s registers into the stored fields.
size_t formatTime(char * buf, size_t n, int mode =0)
Write the stored time into a buffer, in one of four formats.
size_t printTime(Print & out, int mode =0)
Read the clock and print the time into any Print.
String getTime(int mode)
Read the clock and return the time as a String, in formatTime()’s formats.
float getTemp()
int getValue(int n)
int setAlarm(unsigned int Seconds)
int clearAlarm()

Public Functions Documentation

function DS3231_Logger

DS3231_Logger()

function begin

int begin(
    void 
)

function setTime

int setTime(
    int Year,
    int Month,
    int Day,
    int Hour,
    int Min,
    int Sec
)

function readTime

void readTime()

Read the clock’s registers into the stored fields.

What getValue() and setAlarm() need, and what formatTime() formats. Separated from the formatting so that nothing has to build a string to find out what time it is.

function formatTime

size_t formatTime(
    char * buf,
    size_t n,
    int mode =0
)

Write the stored time into a buffer, in one of four formats.

Parameters:

  • buf Where to write; truncated rather than overrun.
  • n Size of buf, including the terminator. 32 is always enough.
  • mode 0 scientific (YYYY/MM/DD HH:MM:SS), 1 US civilian, 2 US civilian with a 12-hour clock, 1701 stardate.

Return: Characters written, not counting the terminator.

Reads nothing: call readTime() first. This is the one definition of each format; printTime() and getTime() both come through it.

function printTime

size_t printTime(
    Print & out,
    int mode =0
)

Read the clock and print the time into any Print.

Return: Bytes printed.

A File to reach a card, Serial to reach the monitor. No string is built for it.

function getTime

String getTime(
    int mode
)

Read the clock and return the time as a String, in formatTime()’s formats.

function getTemp

float getTemp()

function getValue

int getValue(
    int n
)

function setAlarm

int setAlarm(
    unsigned int Seconds
)

function clearAlarm

int clearAlarm()

Updated on 2026-10-04 at 04:52:16 +0000