-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmax31856.ino
51 lines (42 loc) · 2.06 KB
/
max31856.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <Adafruit_MAX31856.h>
// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31856 max = Adafruit_MAX31856(10, 11, 12, 13);
// use hardware SPI, just pass in the CS pin
//Adafruit_MAX31856 max = Adafruit_MAX31856(10);
void setup() {
Serial.begin(115200);
Serial.println("MAX31856 thermocouple test");
max.begin();
max.setThermocoupleType(MAX31856_TCTYPE_K);
Serial.print("Thermocouple type: ");
switch ( max.getThermocoupleType() ) {
case MAX31856_TCTYPE_B: Serial.println("B Type"); break;
case MAX31856_TCTYPE_E: Serial.println("E Type"); break;
case MAX31856_TCTYPE_J: Serial.println("J Type"); break;
case MAX31856_TCTYPE_K: Serial.println("K Type"); break;
case MAX31856_TCTYPE_N: Serial.println("N Type"); break;
case MAX31856_TCTYPE_R: Serial.println("R Type"); break;
case MAX31856_TCTYPE_S: Serial.println("S Type"); break;
case MAX31856_TCTYPE_T: Serial.println("T Type"); break;
case MAX31856_VMODE_G8: Serial.println("Voltage x8 Gain mode"); break;
case MAX31856_VMODE_G32: Serial.println("Voltage x8 Gain mode"); break;
default: Serial.println("Unknown"); break;
}
}
void loop() {
Serial.print("Cold Junction Temp: "); Serial.println(max.readCJTemperature());
Serial.print("Thermocouple Temp: "); Serial.println(max.readThermocoupleTemperature());
// Check and print any faults
uint8_t fault = max.readFault();
if (fault) {
if (fault & MAX31856_FAULT_CJRANGE) Serial.println("Cold Junction Range Fault");
if (fault & MAX31856_FAULT_TCRANGE) Serial.println("Thermocouple Range Fault");
if (fault & MAX31856_FAULT_CJHIGH) Serial.println("Cold Junction High Fault");
if (fault & MAX31856_FAULT_CJLOW) Serial.println("Cold Junction Low Fault");
if (fault & MAX31856_FAULT_TCHIGH) Serial.println("Thermocouple High Fault");
if (fault & MAX31856_FAULT_TCLOW) Serial.println("Thermocouple Low Fault");
if (fault & MAX31856_FAULT_OVUV) Serial.println("Over/Under Voltage Fault");
if (fault & MAX31856_FAULT_OPEN) Serial.println("Thermocouple Open Fault");
}
delay(1000);
}