MAX31856 Type-T setThermocoupleType not working

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
wyojustin
 
Posts: 42
Joined: Sun Apr 05, 2009 10:41 am

MAX31856 Type-T setThermocoupleType not working

Post by wyojustin »

T-Type thermocouple (value = 7) comes back "unknown" (value = 15)

details
I've just followed this tutorial: https://learn.adafruit.com/adafruit-max ... -amplifier

I've set and checked the type with these commands:

Code: Select all

 
  maxthermo.setThermocoupleType(MAX31856_TCTYPE_T);
  Serial.print("Thermocouple type: ");
  Serial.println(maxthermo.getThermocoupleType());
  Serial.println(MAX31856_TCTYPE_T);
and get this response:

Code: Select all

Thermocouple type: 15
7
Unknown
Thanks for suggestons help you can provide

User avatar
SlowJoe
 
Posts: 1
Joined: Wed Aug 18, 2021 7:39 pm

Re: MAX31856 Type-T setThermocoupleType not working

Post by SlowJoe »

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.

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: MAX31856 Type-T setThermocoupleType not working

Post by adafruit_support_carter »

Check your wiring. In general, that should work. Just tested your code snippet here and it works as expected:
Screenshot from 2021-08-20 08-58-28.png
Screenshot from 2021-08-20 08-58-28.png (18.44 KiB) Viewed 467 times

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”