K type thermocouple and MAX31856

I am trying to measure the temperature and for the same, I am using Arduino UNO, K-type thermocouple, and MAX31856.

I am using MAX31856 library code:

#include <SPI.h>
#include <Adafruit_MAX31856.h>

// Create the MAX31856 thermocouple object with the defined pins
Adafruit_MAX31856 max = Adafruit_MAX31856(10, 11, 12, 13); // CS, SDI, SDO, SCK

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10); // wait for serial port to open

  // Initialize the MAX31856 sensor
  if (!max.begin()) {
    Serial.println("Could not initialize MAX31856. Check your wiring!");
    while (1);
  }
  
  // Set thermocouple type
  max.setThermocoupleType(MAX31856_TCTYPE_K);

  // Print the thermocouple type
  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 x32 gain mode"); break;
    default: Serial.println("Unknown"); break;
  }
}

void loop() {
  // Read and print the temperature
//  Serial.print("Cold Junction Temperature: ");
//  Serial.print(max.readCJTemperature());
//  Serial.println(" °C");
  
  //Serial.print("Thermocouple Temperature: ");
  Serial.print(max.readThermocoupleTemperature());
  Serial.println(" °C");
  
  delay(1000);
}


But the output is showing 30.37, 30.74 etc, even after changing the temperature the output value is not being changed.

show your schematic

TRy this sketch
It will print extra information

// Basic example using one-shot measurement.
// The call to readThermocoupleTemperature() is blocking for O(100ms)

#include <Adafruit_MAX31856.h>

// Use software SPI: CS, DI, DO, CLK
// Adafruit_MAX31856 maxthermo = Adafruit_MAX31856(10, 11, 12, 13);
// use hardware SPI, just pass in the CS pin
Adafruit_MAX31856 maxthermo = Adafruit_MAX31856(10);

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10);
  Serial.println("MAX31856 thermocouple test");

  maxthermo.begin();

  maxthermo.setThermocoupleType(MAX31856_TCTYPE_K);

  Serial.print("Thermocouple type: ");
  switch (maxthermo.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(maxthermo.readCJTemperature());

  Serial.print("Thermocouple Temp: ");
  Serial.println(maxthermo.readThermocoupleTemperature());
  // Check and print any faults
  uint8_t fault = maxthermo.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);
}

k-type not showed. it have polarity, are you connected it right?

It's showing the same output.

Yeah I did, even I have checked it with AD8495 it's working fine but with MAX31856 it's not giving proper results.

No the output is different.
Now it prints the cold junction temperature and the thermocouple temperature and there are no faults.

30 degrees is somewhat high, where is the board?

This is the normal temperature at my place, 30 degree Celsius.

Then it looks like it is working.
How did you heat the thermocouple to see if the temperature changed?

I am using cold water and using a candle for checking the temperature variations but there is no output change.

you say "now repaired"?

No still the same.

Does the thermocouple have a metal enclosure at the end?
How long did you leave it in the flame?

No, it's soldered one.
Just for 1 second.

One second is not long enough but that type should NOT be exposet to an open flame.
Ice water should work.

Ok, I just checked the thermocouple with AD8495 to verify if it's fine or not. So it's giving perfect results.

But still facing the same issue with MAX31856. Maybe I will try to buy another MAX sensor.

Are you using my code?

Yes, I am using your code.

It's odd because the coldjunction and thermocouple temperatures are almost the same and there are no faults which all indicate that everything is OK