user29436: In my current project I am measuring temperature using K-type thermocouple and MAX31855 breakout board and Arduino uno.
I have used Adafruit-max31855 library and example code from that library. But monitoring on serial monitor after some reading it is giving NaN.
Here is the code I have used:
#include "Adafruit_MAX31855.h"

int thermoDO = 5;
int thermoCS = 6;
int thermoCLK = 7;

Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);

void setup() {
  Serial.begin(9600);

  Serial.println("MAX31855 test");
  // wait for MAX chip to stabilize
  delay(500);
}

void loop() {
  // basic readout test, just print the current temp
   Serial.print("Internal Temp = ");
   Serial.println(thermocouple.readInternal());

   double c = thermocouple.readCelsius();
   if (isnan(c)) {
     Serial.println("Something wrong with thermocouple!");
   } else {
     Serial.print("C = "); 
     Serial.println(c);
   }
   //Serial.print("F = ");
   //Serial.println(thermocouple.readFarenheit());

   delay(1000);
}

Circuit Diagram:

Output:

What could be the possible error for this and how can I solve this?

user7508: Try to Serial.println(thermocouple.readError()). It will give you an
error code, which is a bit field:

1 = open circuit
2 = short to ground
4 = short to Vcc

C.f. the
datasheet.

29436: <p>In my current project I am measuring temperature using K-type thermocouple and MAX31855 breakout board and Arduino uno.</p>

<p>I have used Adafruit-max31855 library and example code from that library. But monitoring on serial monitor after some reading it is giving <strong>NaN</strong>.</p>

<p>Here is the code I have used:</p>

<pre><code>#include "Adafruit_MAX31855.h"

int thermoDO = 5;
int thermoCS = 6;
int thermoCLK = 7;

Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);

void setup() {
  Serial.begin(9600);

  Serial.println("MAX31855 test");
  // wait for MAX chip to stabilize
  delay(500);
}

void loop() {
  // basic readout test, just print the current temp
   Serial.print("Internal Temp = ");
   Serial.println(thermocouple.readInternal());

   double c = thermocouple.readCelsius();
   if (isnan(c)) {
     Serial.println("Something wrong with thermocouple!");
   } else {
     Serial.print("C = "); 
     Serial.println(c);
   }
   //Serial.print("F = ");
   //Serial.println(thermocouple.readFarenheit());

   delay(1000);
}
</code></pre>

<p>Circuit Diagram:</p>

<p><a href="https://i.stack.imgur.com/fh63x.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fh63x.jpg" alt="max31855 arduino"></a></p>

<p>Output:</p>

<p><a href="https://i.stack.imgur.com/2MvKI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2MvKI.png" alt="output"></a></p>

<p>What could be the possible error for this and how can I solve this?</p>
 7508: <p>Try to <code>Serial.println(thermocouple.readError())</code>. It will give you an
error code, which is a bit field:</p>

<ul>
<li>1 = open circuit</li>
<li>2 = short to ground</li>
<li>4 = short to Vcc</li>
</ul>

<p>C.f. the
<a href="https://cdn-shop.adafruit.com/datasheets/MAX31855.pdf#page=10" rel="nofollow noreferrer">datasheet</a>.</p>
