MaximDS3231 class

The Sensor sub-class for the Maxim DS3231 when used as a low-accuracy temperature sensor.

Only need a sleep and wake since these DON'T use the default of powering up and down

Base classes

class Sensor
The "Sensor" class is used for all sensor-level operations - waking, sleeping, and taking measurements.

Constructors, destructors, conversion operators

MaximDS3231(uint8_t measurementsToAverage = 1) explicit
Construct a new Maxim DS3231 object.
~MaximDS3231()
Destroy the Maxim DS3231 object.

Public functions

String getSensorLocation(void) -> String override
Get the pin or connection location between the mcu and the sensor.
bool setup(void) -> bool override
Do any one-time preparations needed before the sensor will be able to take readings.
bool startSingleMeasurement(void) -> bool override
Tell the sensor to start a single measurement, if needed.
bool addSingleMeasurementResult(void) -> bool override
Get the results from a single measurement.

Function documentation

MaximDS3231::MaximDS3231(uint8_t measurementsToAverage = 1) explicit

Construct a new Maxim DS3231 object.

Parameters
measurementsToAverage The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 1.

String MaximDS3231::getSensorLocation(void) override

Get the pin or connection location between the mcu and the sensor.

Returns String Text describing how the sensor is attached to the mcu.

bool MaximDS3231::setup(void) override

Do any one-time preparations needed before the sensor will be able to take readings.

Returns bool True if the setup was successful.

This starts communication with the RTC (if it had not already been started). This will also turn off any interrupts currently scheduled on the RTC. The clock should be continuously powered, so we never need to worry about power up.


bool MaximDS3231::startSingleMeasurement(void) override

Tell the sensor to start a single measurement, if needed.

Returns bool True if the start measurement function completed successfully. successfully.

This also sets the _millisMeasurementRequested timestamp.


bool MaximDS3231::addSingleMeasurementResult(void) override

Get the results from a single measurement.

Returns bool True if the function completed successfully.

This asks the sensor for a new result, verifies that it passes sanity range checks, and then adds the value to the result array.

This also un-sets the _millisMeasurementRequested timestamp (sets _millisMeasurementRequested to 0) and updates the _sensorStatus.