I am fairly new to Arduino, and have not used this type of thermocouple setup before. Trying to familiarize myself, I am starting slow by just trying to get the Arduino to print out the temperature. I've used this guide to wire everything up, and I have no reason to believe anything is physically wrong. There are no errors when compiling.
I'd appreciate any help very much!
Here's my code:
#include "max6675.h"
int thermoDO = 8;
int thermoCS = 9;
int thermoCLK = 10;
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);
}
Like I said, output to the serial monitor is just "C=0; F=32;" over and over again.
Thanks for your reply. I've wired everything exactly as the guide shows .
And I have the exact same MAX6675 module as in the guide, but am using a different K-type thermocouple, and used a bit of the manufacturer's reference code.
I'm using an Elegoo Uno R3.
#include "max6675.h"
int thermoDO = 8;
int thermoCS = 9;
int thermoCLK = 10;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
int vccPin = 3;
int gndPin = 2;
void setup() {
Serial.begin(9600);
pinMode(vccPin, OUTPUT);
digitalWrite(vccPin, HIGH);
pinMode(gndPin, OUTPUT);
digitalWrite(gndPin, LOW);
Serial.println("MAX6675 test");
delay(500);
}
void loop() {
Serial.print("Deg C = ");
Serial.println( thermocouple.readCelsius() );
Serial.print("Deg F = ");
Serial.println( thermocouple.readFahrenheit() );
delay(1000);
}
This is all coming from the guide I linked, as well as from an example in the linked MAX6675 github library I installed. I've tried commenting out the lines in void setup() involving pinMode and digitalWrite so it exactly matches the code in the guide, and I still get C=0, F=32. With those lines active, I get same results.
Perhaps you have wired the thermocouple backwards, or have a bad contact. The chip is either defective, or not being presented with the expected type of thermocouple.
My main concern with the code is that digital pins used for ground are not actually ground. For such low level inputs as thermocouples, that could make a huge difference.
jremington:
Perhaps you have wired the thermocouple backwards, or have a bad contact.
I'm certain it isn't wired backwards. The thermocouple I'm using actually has marking for the polarity, so I followed that.
With regards to the ground - I've tried two things: first, the guide here is what I am using for the overarching project. It says to wire the cables from the MAX to pins 2->6 on the Arduino. Second, which I believe to be a better option, is from the guide I linked previously. I wired the VCC and GND to their respective places on the Arduino, and the other three connectors to three digital pins.
bendl:
Look at your loop statement.
What exactly is it doing?
You haven't used any of your
variables in the loop
I was under the impression that the thermocouple.readCelsius (and F) lines were drawing from the max6675 library, and referencing the variables I defined earlier.
In the interest of keeping things simple lets start with the code.
// Sample Arduino MAX6675 Arduino Sketch
#include "max6675.h"
int ktcSO = 8;
int ktcCS = 9;
int ktcCLK = 10;
MAX6675 ktc(ktcCLK, ktcCS, ktcSO);
void setup() {
Serial.begin(9600);
// give the MAX a little time to settle
delay(500);
}
void loop() {
// basic readout test
Serial.print("Deg C = ");
Serial.print(ktc.readCelsius());
Serial.print("\t Deg F = ");
Serial.println(ktc.readFahrenheit());
delay(500);
}
I would just copy and paste the code exactly as the quick start tutorial reflects. Sometimes code samples contain plenty of descriptive remarks and sometimes not so much. This is the latter but try and follow it. Just stick to the sample code and only once that works worry about tweaks and peaks changes.
The module connections are pretty straight forward VCC is 5 Volts from your Arduino board and GND is Ground board to board. The three remaining pins, Serial Clock, Chip Select and Data go to pins 10, 9, and 8 respectively, just like the picture.
What is this all about?
Serial.print("Deg C = ");
Serial.println( thermocouple.readCelsius() );
Serial.print("Deg F = ");
Serial.println( thermocouple.readFahrenheit() );
That is not what I see in the sample code?
Also in the beginning
int vccPin = 3;
int gndPin = 2;
The VCC pin (power) is taken from the % volt out pin on the Arduino board as is Ground to Ground. You are not powering the module from those pins.
For now just copy and past the sample code into your project and lets see if it works,
Hi Ron, Thank you so much for your thorough reply. I started a new sketch, put in exactly that sample code and nothing more, uploaded it, and am still getting C=0 F=32. I'm going to go through and redo all of my electrical taping and make sure things have very solid contact and will report back.
Success (for now)! Getting accurate temperature readings after I redid all of the wiring and crafted this clamp (Imgur: The magic of the Internet) to ensure the wires to the thermocouple have good contact. Going to make a neater version later on. Thanks everyone for your help.
matthewlese:
Success (for now)! Getting accurate temperature readings after I redid all of the wiring and crafted this clamp (Imgur: The magic of the Internet) to ensure the wires to the thermocouple have good contact. Going to make a neater version later on. Thanks everyone for your help.
Or you could just get the mating connector for your standard thermocouple connector.
matthewlese:
Success (for now)! Getting accurate temperature readings after I redid all of the wiring and crafted this clamp (Imgur: The magic of the Internet) to ensure the wires to the thermocouple have good contact. Going to make a neater version later on. Thanks everyone for your help.
Over a lot of years and countless thermocouples I figured I had seen every connector imaginable. Well go figure there is a new one.
Yeah, you may want to get a mating connector. Glad it is now working.