Skip to content
Michael Miller edited this page Jul 16, 2019 · 3 revisions

(under construction)
RtcDS3234 object provides access to all the functions of the DS3234 module. Along with date and time, this also includes setting alarms, retrieving the temperature, enabling the 32 kHz pin, and defining the square wave pin.

Constructors

template<class T_SPI_METHOD> RtcDS3234(T_SPI_METHOD& spi)

Construct a Rtc object using the provided WIRE method.
T_SPI_METHOD - the typename of the class to use for the wire method. SPIClass is the normal hardware method class.
spi - the instance of the T_SPI_METHOD to use. SPI is the normal hardware instance to use.
Below is an example of how to create an instance of the object using the normal Arduino hardware SPI support.

#include <SPI.h> 
#include <RtcDS3234.h>

RtcDS3234<SPIClass> Rtc(SPI);

If you want to use SoftwareWire library, you can replace the class and instance from the above with the one you include.

Methods

void Begin()

The normal begin method that should be called within Setup()

bool IsDateTimeValid()

<return>, the RTC has confidence in the date and time it returns. If this returns false it usually means the battery is dead or the date and time has never been set.

bool GetIsRunning()

<return>, the actual clock is running on the RTC.

void SetIsRunning(bool isRunning)

isRunning - set if the clock is running. If false then the time value will not progress.

void SetDateTime(const RtcDateTime& dt)

dt - the date and time to set the RTC to.

RtcDateTime GetDateTime()

<return>, the current date and time in the RTC.

RtcTemperature GetTemperature()

<return>, the temperature the module is current reading

void Enable32kHzPin(bool enable)

This will turn off and on the special pin that will give a pulse at 32kHz rate.
enable - true to enable the pin, false to disable it

void SetSquareWavePin(DS3234SquareWavePinMode pinMode)

piMode - the mode to have the SquareWave pin act as. One of the following values valid.
DS3234SquareWavePin_ModeNone - disable the pin
DS3234SquareWavePin_ModeBatteryBackup - the pin will trigger when the external power is lower than the battery power
DS3234SquareWavePin_ModeClock - the pin will trigger at the frequency defined by SetSquareWavePinClockFrequency()
DS3234SquareWavePin_ModeAlarmOne - the pin will trigger with alarm one
DS3234SquareWavePin_ModeAlarmTwo - the pin will trigger with alarm two
DS3234SquareWavePin_ModeAlarmBoth - the pin will trigger with either of the alarms

void SetSquareWavePinClockFrequency(DS3234SquareWaveClock freq)

When the SquareWave pin is enabled for the clock, this method will set at what frequency the pin will pulse.
freq - One of the follow is used to control it.
DS3234SquareWaveClock_1Hz - one per second
DS3234SquareWaveClock_1kHz - 1024 times per second
DS3234SquareWaveClock_4kHz - 4096 times a second
DS3234SquareWaveClock_8kHz - 8192 times a second

void SetAlarmOne(const DS3234AlarmOne& alarm)

Alarm one allows for setting an alarm that is accurate to the second with various modes.
alarm - a structure that defines all the properties to set the alarm one.

DS3234AlarmOne GetAlarmOne()

this will get the current settings for alarm one.
<return>, the structure for the current settings

void SetAlarmTwo(const DS3234AlarmTwo& alarm)

Alarm two allows for setting an alarm that is accurate to the minute with various modes.
alarm - a structure that defines all the properties to set the alarm two.

DS3234AlarmTwo GetAlarmTwo()

this will get the current settings for alarm two.
<return>, the structure for the current settings

DS3234AlarmFlag LatchAlarmsTriggeredFlags()

This method must be called after an alarm is triggered otherwise it will not trigger again. It is used as a means to confirm you handled the alarm.
<return>, the flag that defines which alarms were still active when this method is called. The values can be checked using bit operations.
DS3234AlarmFlag_Alarm1 - flag value for alarm 1
DS3234AlarmFlag_Alarm2 - flag value for alarm 2
DS3234AlarmFlag_AlarmBoth - a value handy for checking for both

void ForceTemperatureCompensationUpdate(bool block)

This will trigger a temperature compensation update internally to the RTC. This is used to more accurately keep time. It is rare that this needed as it already happens automatically about every 64 seconds.
block - set to true to not return from this call until the compensation update is finished.

int8_t GetAgingOffset()

(see DS3234 documentation)
Normal operation to keep the RTC Module within its accuracy specification does not require the user to manipulation the aging offset.

void SetAgingOffset(int8_t value)

(see DS3234 documentation)
Normal operation to keep the RTC Module within its accuracy specification does not require the user to manipulation the aging offset.

void SetMemory(uint8_t memoryAddress, uint8_t value)

memoryAddress - (0-54) the address within the memory of the RTC to store a value.
value - the 8 bit value to store.

uint8_t GetMemory(uint8_t memoryAddress)

memoryAddress - the address within the memory of the RTC to retrieve a value.
<return>, the value of that memory address

uint8_t SetMemory(uint8_t memoryAddress, const uint8_t* pValue, uint8_t countBytes)

memoryAddress - the starting address within the memory of the RTC to copy the following buffer
pValue - the pointer to a buffer of bytes
countBytes - the number of bytes to copy
<return>, the number of bytes actually copied. This maybe smaller than countBytes due to reaching the end of the available memory address.

uint8_t GetMemory(uint8_t memoryAddress, uint8_t* pValue, uint8_t countBytes)

memoryAddress - the starting address within the memory of the RTC to copy from
pValue - the pointer to a buffer of bytes to copy into
countBytes - the number of bytes to copy
<return>, the number of bytes actually copied. This maybe smaller than countBytes due to reaching the end of the available memory address.

Clone this wiki locally