Skip to content
Michael Miller edited this page Jul 28, 2023 · 1 revision

RtcDS3232 object provides access to all the functions of the DS3232 module. Along with date and time, this also includes setting alarms, retrieving the temperature, enabling the 32 kHz pin, defining the square wave pin, and accessing the SRAM.

The DS3232 is 100% compatible with the DS3231 but with the addition of SRAM memory. Due to this, most of the constants used for the RtcDS3231 are used with the RtcDS3232 and only the differences in the API are listed below.

See RtcDS3231 object for details on it.

Constructors

template<class T_WIRE_METHOD> RtcDS3232(T_WIRE_METHOD& wire)

Construct a Rtc object using the provided WIRE method.
T_WIRE_METHOD - the typename of the class to use for the wire method. TwoWire is the normal hardware method class.
wire - the instance of the T_WIRE_METHOD to use. Wire 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 Wire support.

#include <Wire.h> 
#include <RtcDS3232.h>

RtcDS3232<TwoWire> Rtc(Wire);

If you want to use SoftwareWire library, you can replace the above with this and it will work.

#include <SoftwareWire.h> 
#include <RtcDS3232.h>

SoftwareWire myWire(SDA, SCL); // replace with the pins you use
RtcDS3232<SoftwareWire> Rtc(myWire);

Methods

See the RtcDS3231 object methods for the full list of compatible methods.

void SetMemory(uint8_t memoryAddress, uint8_t value)

memoryAddress - (0-235) 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 - (0-235) 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 - (0-235) 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. Due to limitations of the underlying buffer size for the Wire object, this is often restricted to only 32 bytes at any one call.
<return>, the number of bytes actually copied. This may be 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 - (0-235) 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. Due to limitations of the underlying buffer size for the Wire object, this is often restricted to only 32 bytes at any one call.
<return>, the number of bytes actually copied. This may be smaller than countBytes due to reaching the end of the available memory address.