Maxim DS3231 RTC topic
- Introduction
- Sensor Datasheet
- Sensor Constructor
- Example Code
- Reference
- Detailed Descriptions
Classes for the Maxim DS3231 high-precision, temperature-corrected real-time clock.
Introduction
The I2C Maxim DS3231 real time clock (RTC) is absolutely required for time-keeping on all AVR boards. This library also makes use of of the DS3231 for its on-board temperature sensor. This temperature is not equivalent to an environmental temperature measurement and should only be used to as a diagnostic. Internally, the DS3231 uses the temperature it measures to compensate for temperature variation in the crystal speed. This improves the timekeeping accuracy and reduces time drift.
The DS3231 requires a 3.3V power supply and most breakouts or boards that integrate the DS3231 (including the Mayfly) use a coin battery to supply the clock. Using separate power supply for the clock prevents the time from resetting if the main board loses power.
Sensor Datasheet
Sensor Constructor
Construct a new Maxim DS3231 object.
MaximDS3231::
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.
Example Code
The Maxim DS3231 RTC is used in nearly all of the examples, including the menu a la carte example.
Classes
- class MaximDS3231
- The Sensor sub-class for the Maxim DS3231 when used as a low-accuracy temperature sensor.
- class MaximDS3231_Temp
- The Variable sub-class used for the temperature output from a DS3231.
Sensor Variable Counts
The number of variables that can be returned by the DS3231
- #define DS3231_NUM_VARIABLES = 1
- Sensor::
_numReturnedValues; the DS3231 can report 1 value. - #define DS3231_INC_CALC_VARIABLES = 0
- Sensor::
_incCalcValues; we don't calculate any additional values.
Sensor Timing
The sensor timing for a Maxim DS18 RTC
- #define DS3231_WARM_UP_TIME_MS = 0
- Sensor::
_warmUpTime_ms; the DS3231 should never be powered off so there is no warm-up time. - #define DS3231_STABILIZATION_TIME_MS = 0
- Sensor::
_stabilizationTime_ms; the DS3231 should never be powered off so there is no stabilization time. - #define DS3231_MEASUREMENT_TIME_MS = 200
- Sensor::
_measurementTime_ms; the DS3231 takes 200ms to complete a measurement - A single temperature conversion takes 200ms.
Temperature
The temperature variable from a Maxim DS18 RTC
- Range is -55°C to 125°C
- Accuracy: ± 3°C
Construct a new MaximDS3231_
MaximDS3231_
Parameters
parentSense
The parent MaximDS3231 providing the result values.
uuid
A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode
A short code to help identify the variable in files; optional with a default value of "BoardTemp".
- #define DS3231_TEMP_RESOLUTION = 2
- Decimals places in string representation; temperature should have 2 - resolution is -0.25°C (10 bit).
- #define DS3231_TEMP_VAR_NUM = 0
- Sensor variable number; temperature is stored in sensorValues[0].
- #define DS3231_TEMP_VAR_NAME = "temperatureDatalogger"
- Variable name in ODM2 controlled vocabulary; "temperatureDatalogger".
- #define DS3231_TEMP_UNIT_NAME = "degreeCelsius"
- Variable unit name in ODM2 controlled vocabulary; "degreeCelsius" (°C)
- #define DS3231_TEMP_DEFAULT_CODE = "BoardTemp"
- Default variable short code; "BoardTemp".
Define documentation
#define DS3231_NUM_VARIABLES = 1
#include <src/sensors/MaximDS3231.h>
Sensor::
#define DS3231_INC_CALC_VARIABLES = 0
#include <src/sensors/MaximDS3231.h>
Sensor::
#define DS3231_WARM_UP_TIME_MS = 0
#include <src/sensors/MaximDS3231.h>
Sensor::
#define DS3231_STABILIZATION_TIME_MS = 0
#include <src/sensors/MaximDS3231.h>
Sensor::
#define DS3231_MEASUREMENT_TIME_MS = 200
#include <src/sensors/MaximDS3231.h>
Sensor::
#define DS3231_TEMP_RESOLUTION = 2
#include <src/sensors/MaximDS3231.h>
Decimals places in string representation; temperature should have 2 - resolution is -0.25°C (10 bit).
#define DS3231_TEMP_VAR_NUM = 0
#include <src/sensors/MaximDS3231.h>
Sensor variable number; temperature is stored in sensorValues[0].
#define DS3231_TEMP_VAR_NAME = "temperatureDatalogger"
#include <src/sensors/MaximDS3231.h>
Variable name in ODM2 controlled vocabulary; "temperatureDatalogger".
#define DS3231_TEMP_UNIT_NAME = "degreeCelsius"
#include <src/sensors/MaximDS3231.h>
Variable unit name in ODM2 controlled vocabulary; "degreeCelsius" (°C)
#define DS3231_TEMP_DEFAULT_CODE = "BoardTemp"
#include <src/sensors/MaximDS3231.h>
Default variable short code; "BoardTemp".