-
Notifications
You must be signed in to change notification settings - Fork 7
fault()
Arnd edited this page Nov 30, 2020
·
5 revisions
faultCode = fault();
This function returns 0 when no fault is detected in the MAX31855 setup, otherwise one of the following three possible error codes is set:
- 1 Thermocouple wire is not connected
- 2 Thermocouple is short-circuited to GROUND
- 4 Thermocouple is short-circuited to VCC (positive current)
Note that the fault codes are cumulative bit values, so an error code of 3 would be the sum of errors 1 and 2.
#include <MAX31855.h> // MAX31855 Thermocouple Library
...
const uint8_t CS_PIN = 2;
MAX31855_Class device;
...
device.begin();
int32_t ambientTemperature = device.readAmbient();
uint8_t faultCode = device.fault();
if (faultCode) {
Serial.print("Probe has error number ");
Serial.println(faultCode);
if (faultCode & 1) { Serial.println(F("Fault: Wire not connected")); }
if (faultCode & 2) { Serial.println(F("Fault: Short-circuited to Ground (negative)")); }
if (faultCode & 4) { Serial.println(F("Fault: Short-circuited to VCC (positive)")); }
} // of if-then fault
...