Alejandro Lara / DS3231
Embed: (wiki syntax)

« Back to documentation index

RTC_DS3231 Class Reference

RTC_DS3231 Class Reference

RTC based on the DS3231 chip connected via I2C and the Wire library. More...

#include <RTClib.h>

Public Member Functions

bool begin (void)
 Start I2C for the DS3231 and test succesful connection.
void adjust (const DateTime &dt)
 Set the date and flip the Oscillator Stop Flag.
bool lostPower (void)
 Check the status register Oscillator Stop Flag to see if the DS3231 stopped due to power loss.
DateTime now ()
 Get the current date/time.
Ds3231SqwPinMode readSqwPinMode ()
 Read the SQW pin mode.
void writeSqwPinMode (Ds3231SqwPinMode mode)
 Set the SQW pin mode.
float getTemperature ()
 Get the current temperature from the DS3231's temperature sensor.
uint8_t read_i2c_register (uint8_t addr, uint8_t reg)
 Read a uint8_t from an I2C register.
void write_i2c_register (uint8_t addr, uint8_t reg, uint8_t val)
 Write a uint8_t to an I2C register.

Detailed Description

RTC based on the DS3231 chip connected via I2C and the Wire library.

Definition at line 271 of file RTClib.h.


Member Function Documentation

void adjust ( const DateTime dt )

Set the date and flip the Oscillator Stop Flag.

Parameters:
dtDateTime object containing the date/time to set

Definition at line 610 of file RTClib.cpp.

bool begin ( void   )

Start I2C for the DS3231 and test succesful connection.

Returns:
True if Wire can find DS3231 or false otherwise.

Definition at line 583 of file RTClib.cpp.

float getTemperature (  )

Get the current temperature from the DS3231's temperature sensor.

Returns:
Current temperature (float)

Definition at line 694 of file RTClib.cpp.

bool lostPower ( void   )

Check the status register Oscillator Stop Flag to see if the DS3231 stopped due to power loss.

Returns:
True if the bit is set (oscillator stopped) or false if it is running

Definition at line 599 of file RTClib.cpp.

DateTime now (  )

Get the current date/time.

Returns:
DateTime object with the current date/time

Definition at line 634 of file RTClib.cpp.

uint8_t read_i2c_register ( uint8_t  addr,
uint8_t  reg 
)

Read a uint8_t from an I2C register.

Parameters:
addrI2C address
regRegister address
Returns:
Register value

Definition at line 56 of file RTClib.cpp.

Ds3231SqwPinMode readSqwPinMode (  )

Read the SQW pin mode.

Returns:
Pin mode, see Ds3231SqwPinMode enum

Definition at line 654 of file RTClib.cpp.

void write_i2c_register ( uint8_t  addr,
uint8_t  reg,
uint8_t  val 
)

Write a uint8_t to an I2C register.

Parameters:
addrI2C address
regRegister address
valValue to write

Definition at line 77 of file RTClib.cpp.

void writeSqwPinMode ( Ds3231SqwPinMode  mode )

Set the SQW pin mode.

Parameters:
modeDesired mode, see Ds3231SqwPinMode enum

Definition at line 670 of file RTClib.cpp.