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 current date and time from DS1307. More...
 
Ds1307SqwPinMode   readSqwPinMode()
  Read current mode of 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
wireInstance pointer to the I2C bus
ReturnsTrue if Wire can find DS1307 or false otherwise.

adjust()

void RTC_DS1307::adjust ( const DateTime dt )

Set date and time in DS1307.

Parameters
dt DateTime 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.

Returns1 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.

ReturnsMode as Ds1307SqwPinMode enum

writeSqwPinMode()

void RTC_DS1307::writeSqwPinMode ( Ds1307SqwPinMode   mode )

Change the SQW pin mode.

Parameters
mode The mode to use

readnvram() [1/2]

uint8_t RTC_DS1307::readnvram ( uint8_t  address )

Shortcut to read one byte from NVRAM.

Parameters
address NVRAM address, 0 to 55
ReturnsThe 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
buf Pointer to a buffer to store the data - make sure it's large enough to hold size bytes
size Number of bytes to read
address Starting 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
address NVRAM address, 0 to 55
data One 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
address Starting NVRAM address, from 0 to 55
buf Pointer to buffer containing the data to write
size Number of bytes in buf to write to NVRAM