RTClib
Public Member Functions | List of all members
RTC_DS1307 Class Reference

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

#include <RTClib.h>

Inheritance diagram for RTC_DS1307:
RTC_I2C

Public Member Functions

bool begin (TwoWire *wireInstance=&Wire)
 Start I2C for the DS1307 and test succesful connection. More...
 
void adjust (const DateTime &dt)
 Set the date and time in the DS1307. More...
 
uint8_t isrunning (void)
 Is the DS1307 running? Check the Clock Halt bit in register 0. More...
 
DateTime now ()
 Get the current date and time from the DS1307. More...
 
Ds1307SqwPinMode readSqwPinMode ()
 Read the current mode of the SQW pin. More...
 
void writeSqwPinMode (Ds1307SqwPinMode mode)
 Change the SQW pin mode. More...
 
uint8_t readnvram (uint8_t address)
 Shortcut to read one byte from NVRAM. More...
 
void readnvram (uint8_t *buf, uint8_t size, uint8_t address)
 Read data from the DS1307's NVRAM. More...
 
void writenvram (uint8_t address, uint8_t data)
 Shortcut to write one byte to NVRAM. More...
 
void writenvram (uint8_t address, const uint8_t *buf, uint8_t size)
 Write data to the DS1307 NVRAM. More...
 

Detailed Description

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

Member Function Documentation

◆ begin()

bool RTC_DS1307::begin ( TwoWire *  wireInstance = &Wire)

Start I2C for the DS1307 and test succesful connection.

Parameters
wireInstancepointer to the I2C bus
Returns
True if Wire can find DS1307 or false otherwise.

◆ adjust()

void RTC_DS1307::adjust ( const DateTime dt)

Set the date and time in the DS1307.

Parameters
dtDateTime object containing the desired date/time

◆ isrunning()

uint8_t RTC_DS1307::isrunning ( void  )

Is the DS1307 running? Check the Clock Halt bit in register 0.

Returns
1 if the RTC is running, 0 if not

◆ now()

DateTime RTC_DS1307::now ( )

Get the current date and time from the DS1307.

Returns
DateTime object containing the current date and time

◆ readSqwPinMode()

Ds1307SqwPinMode RTC_DS1307::readSqwPinMode ( )

Read the current mode of the SQW pin.

Returns
Mode as Ds1307SqwPinMode enum

◆ writeSqwPinMode()

void RTC_DS1307::writeSqwPinMode ( Ds1307SqwPinMode  mode)

Change the SQW pin mode.

Parameters
modeThe mode to use

◆ readnvram() [1/2]

uint8_t RTC_DS1307::readnvram ( uint8_t  address)

Shortcut to read one byte from NVRAM.

Parameters
addressNVRAM address, 0 to 55
Returns
The byte read from NVRAM

◆ readnvram() [2/2]

void RTC_DS1307::readnvram ( uint8_t *  buf,
uint8_t  size,
uint8_t  address 
)

Read data from the DS1307's NVRAM.

Parameters
bufPointer to a buffer to store the data - make sure it's large enough to hold size bytes
sizeNumber of bytes to read
addressStarting NVRAM address, from 0 to 55

◆ writenvram() [1/2]

void RTC_DS1307::writenvram ( uint8_t  address,
uint8_t  data 
)

Shortcut to write one byte to NVRAM.

Parameters
addressNVRAM address, 0 to 55
dataOne byte to write

◆ writenvram() [2/2]

void RTC_DS1307::writenvram ( uint8_t  address,
const uint8_t *  buf,
uint8_t  size 
)

Write data to the DS1307 NVRAM.

Parameters
addressStarting NVRAM address, from 0 to 55
bufPointer to buffer containing the data to write
sizeNumber of bytes in buf to write to NVRAM

The documentation for this class was generated from the following files: