-
Notifications
You must be signed in to change notification settings - Fork 0
readTemp()
Arnd edited this page Aug 28, 2017
·
3 revisions
This function returns a signed 16 bit integer representing the temperature of the thermometer requested. The value is in units of 0.0625°C. This has been done so that no floating point is required by the library and the user can choose how to best convert this to Celsius or Fahrenheit (or Kelvin or Rankine). If called with an invalid device number it will return INT16_MIN (-32767).
DS1631_Class DS1631; // Create an instance of the DS1631
...
void setup() {
Serial.begin(SERIAL_SPEED);
while (!DS1631.begin()) { // Initialize I2C communications
Serial.println("Unable to find DS1631. Checking again in 3 seconds.");
delay(3000);
} // of loop until device is located
for (uint8_t i=0;i<DS1631.thermometers;i++) {
Serial.print("Thermometer ");
Serial.print(i);
Serial.print(" = ");
Serial.print(DS1631.readTemp(i)*0.0625,4); // Floating point Celsius//
Serial.println("\xC2\xB0""C");
}
...
} // of setup