MAX6675 Returns 'nan' value

Using the sample code from the library (see below), two different thermocouples (also see below) both provide "nan" as the output. The value does not change based on the temp changing during the program execution. Help?

Thermocouples: SainSmart (MAX6675 came with this thermocouple) and a generic thermocouple.

Sample code (not modified from the example sketch):

// this example is public domain. enjoy! // www.ladyada.net/learn/sensors/thermocouple

include "max6675.h"

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

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO); int vccPin = 3; int gndPin = 2;

void setup() { Serial.begin(9600); // use Arduino pins pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH); pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);

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

void loop() { // basic readout test, just print the current temp

Serial.print("C = "); Serial.println(thermocouple.readCelsius()); Serial.print("F = "); Serial.println(thermocouple.readFahrenheit());

delay(1000); }

Sample Output: MAX6675 test C = nan F = nan C = nan F = nan ...

I have seen alot of discussion surrounding "grounded" thermocouples, as most of the ones that I have seen sold for and with Arduino boards are all part of the body of the device, this should be a wider problem. It is also very likely that I have missed something basic - and indeed, I hope that is the case. Thank you in advance for any help/advice you can provide!

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

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO); int vccPin = 3; int gndPin = 2;

Make sure your pins are correct

Also, a broken thermocouple will give the same result

Hi,

I guess that i have the same problem than Josh, my arduino is returning NAN or an useless value.

I use a card max6675 and the adafruit library (https://github.com/adafruit/MAX6675-library) I tried with 3 different K-TC coming from ( https://www.tcdirect.fr/Default.aspx?level=2&department_id=190/1)

My code is the following:

// this example is public domain. enjoy!// www.ladyada.net/learn/sensors/thermocouple

include "max6675.h"

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

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO); int vccPin = 3; int gndPin = 2;

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

// use Arduino pins pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH); pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW); Serial.println("MAX6675 test"); // wait for MAX chip to stabilize delay(500); }

void loop() { // basic readout test, just print the current temp Serial.print("C = "); Serial.println(thermocouple.readCelsius()); Serial.print("F = "); Serial.println(thermocouple.readFahrenheit()); delay(1000); }

Anyone has an idea to solve this ? Josh did you solve your problem ?

Thanks

Different Arduino boards have different SPI pins:

This sensor uses SPI bus to communicate, specials pins are required to interface Board: MOSI MISO SCLK SS, don't use for CS Level Uno, Mini, Pro, ATmega168, ATmega328..... 11 12 13 10 5v Mega, Mega2560, ATmega1280, ATmega2560... 51 50 52 53 5v Due, SAM3X8E............................. ICSP4 ICSP1 ICSP3 x 3.3v Leonardo, ProMicro, ATmega32U4........... 16 14 15 x 5v Blue Pill, STM32F103xxxx boards.......... PA17 PA6 PA5 PA4 3v NodeMCU 1.0, WeMos D1 Mini............... GPIO13/D7 GPIO12/D6 GPIO14/D5 GPIO15/D8* 3v/5v ESP32.................................... GPIO23/D23 GPIO19/D19 GPIO18/D18 x 3v

my library - https://github.com/enjoyneering/MAX6675

enjoyneering: Different Arduino boards have different SPI pins:

my library - https://github.com/enjoyneering/MAX6675

Standard SPI pins are not the only way to connect MAX6675. Their pins will go too.

Teebthib: Anyone has an idea to solve this ? Josh did you solve your problem ?

Thanks

Check the wires. I got the same problem till I fixed the connection.

My library has derived class "MAX6675Soft" for software (bit-bang) ISP. You can use virtually any pins you want.

MAX6675Soft myMAX6675(2, 4, 7); //MAX6675Soft(cs, so, sck)

But I prefer hw ISP.

|500x164