In the Adafruit library example for the MAX31856, the "switch" command is used. At
https://www.arduino.cc/reference/en/lan ... witchcase/ they state:
"Like if statements, switch case controls the flow of programs by allowing programmers to specify different code that should be executed in various conditions. In particular, a switch statement compares the value of a variable to the values specified in case statements. When a case statement is found whose value matches that of the variable, the code in that case statement is run."
When you specify the thermocouple type, the signal from the thermocouple is converted from a millivolt signal to a temperature by comparing that signal with a curve that is characteristic of that thermocouple type. Therefore the library can compensate for non-linearity for each particular type of thermocouple.
The sample code in the Adafruit library is as follows:
Code: Select all
max.begin();
//use max.setThermocoupleType(MAX31856_TCTYPE_T); for type T thermocouple
//use max.setThermocoupleType (MAX31856_VMODE_G32); for voltage output
max.setThermocoupleType(MAX31856_TCTYPE_T);
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;
}
If you leave out the switch command, the library doesn't know which thermocouple code you want to use.
Try the example from the Adafruit_MAX31856.h library and see if it works for you.