Skip to content

temperature()

Arnd edited this page Aug 20, 2017 · 2 revisions

This function returns the internal temperature of the DS3231M chip as a 32-bit integer in deci-degrees Celsius. This is °C times 100, so 27.5°C returns as "2750". This is done so that the accuracy of 0.25°C is maintained while not having to resort to floating point variables. The reading is affected by the temperature of the PCB that the DS3231M is affixed to as well as through the die self-heating and this value will read higher than ambient temperatures.


Example:

...
DS3231M_Class DS3231M; // Create an instance of the DS3231M
...
void setup() {
  Serial.begin(SERIAL_SPEED);
  while (!DS3231M.begin()) { // Initialize RTC communications
    Serial.println("Unable to find DS3231M. Checking again in 1 second.");
    delay(1000);
  } // of loop until device is located
  Serial.print("Device temperature is ");
  Serial.print(DS3231M.temperature()/100.0);
  Serial.println("\xC2\xB0""C");
...
} // of setup
Clone this wiki locally