Last active
January 8, 2021 18:49
-
-
Save greghesp/19c799e76ad166bea2bdce76df82bb83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Adafruit_MAX31865.h> | |
// Use software SPI: CS, DI, DO, CLK | |
//Adafruit_MAX31865 thermo = Adafruit_MAX31865(3, 2, 1, 0); | |
// use hardware SPI, just pass in the CS pin | |
Adafruit_MAX31865 thermo = Adafruit_MAX31865(D1,D2,D3,D4); | |
// The value of the Rref resistor. Use 430.0 for PT100 and 4300.0 for PT1000 | |
#define RREF 430.0 | |
// The 'nominal' 0-degrees-C resistance of the sensorS | |
// 100.0 for PT100, 1000.0 for PT1000 | |
#define RNOMINAL 100.0 | |
void setup() { | |
Serial.begin(9600); | |
Serial.print("Adafruit MAX31865 PT100 Sensor Test!"); | |
thermo.begin(MAX31865_3WIRE); // set to 2WIRE or 4WIRE as necessary | |
} | |
void loop() { | |
uint16_t rtd = thermo.readRTD(); | |
Serial.print("RTD value: "); Serial.println(rtd); | |
float ratio = rtd; | |
ratio /= 32768; | |
Serial.print("Ratio = "); Serial.println(ratio,8); | |
Serial.print("Resistance = "); Serial.println(RREF*ratio,8); | |
Serial.print("Temperature = "); Serial.println(thermo.temperature(RNOMINAL, RREF)); | |
// Check and print any faults | |
uint8_t fault = thermo.readFault(); | |
if (fault) { | |
Serial.print("Fault 0x"); Serial.println(fault, HEX); | |
if (fault & MAX31865_FAULT_HIGHTHRESH) { | |
Serial.println("RTD High Threshold"); | |
} | |
if (fault & MAX31865_FAULT_LOWTHRESH) { | |
Serial.println("RTD Low Threshold"); | |
} | |
if (fault & MAX31865_FAULT_REFINLOW) { | |
Serial.println("REFIN- > 0.85 x Bias"); | |
} | |
if (fault & MAX31865_FAULT_REFINHIGH) { | |
Serial.println("REFIN- < 0.85 x Bias - FORCE- open"); | |
} | |
if (fault & MAX31865_FAULT_RTDINLOW) { | |
Serial.println("RTDIN- < 0.85 x Bias - FORCE- open"); | |
} | |
if (fault & MAX31865_FAULT_OVUV) { | |
Serial.println("Under/Over voltage"); | |
} | |
thermo.clearFault(); | |
} | |
Serial.println(); | |
delay(10000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment