-
Notifications
You must be signed in to change notification settings - Fork 7
readAmbient()
ambientTemperature = readAmbient();
This function returns a signed 32 bit integer which represents the ambient temperature in milli-degrees Celsius. To get degrees Celsius just divide by 1000, e.g. a temperature value of "31530" represents 31.53°C. This is done so that floating point calculations can be avoided while still keeping the device's precision. If the probe has an error the value returned will be INT32_MAX and the fault code can be read using fault().
Note that the temperature is that of the die, which is going to be warmer than the surroundings due to self-warming as well as because it is attached to a PCB which, in turn, will also be warmer than ambient. The ambient temperature reading is used to compute the correct temperature of the thermocouple probe.
#include <MAX31855.h> // MAX31855 Thermocouple Library
...
const uint8_t CS_PIN = 2;
MAX31855_Class device;
...
device.begin();
int32_t ambientTemperature = device.readAmbient();
if (ambientTemperature==INT32_MAX) {
Serial.print("Probe has error ");
Serial.println(device.fault());
} else {
Serial.print("Ambient temperature is ");
Serial.print(AmbientTemperature/1000.0,3); // use floating point division
Serial.println("\xC2\xB0""C"); // Display degree symbol
} // of if-then-else fault
...