-
Notifications
You must be signed in to change notification settings - Fork 7
readProbe()
Arnd edited this page Dec 12, 2020
·
4 revisions
probeTemperature = readProbe();
This function returns a signed 32 bit integer which represents the probe 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().
#include <MAX31855.h> // MAX31855 Thermocouple Library
...
const uint8_t CS_PIN = 2;
MAX31855_Class device;
...
device.begin();
int32_t probeTemperature = device.readProbe();
if (probeTemperature==INT32_MAX) {
Serial.print("Probe has error ");
Serial.println(device.fault());
} else {
Serial.print("Probe temperature is ");
Serial.print(probeTemperature/1000.0,3); // use floating point division
Serial.println("\xC2\xB0""C"); // Display degree symbol
} // of if-then-else fault
...