multiple MAX6675 thermocouple low values

Hi,

I'm pretty new to using my Arduino. I am working with an Arduino mega 2560 using multiple MAX6675 k-type thermocouples. I need 16 of them to take readings from multiple spots. I can get around 8 to work properly and give good readings i.e. reading room temp at room temp and responding to temperature changes. My problem is once I hook up more than that they consistently give lower readings by around 10 degrees Celcius or show 0 degrees occasionally. Is there a limit on the number of thermocouples I can have on a board or am I doing something wrong? Any help is appreciated. My code is below.

#include "max6675.h"            //include MAX library (https://github.com/adafruit/MAX6675-library)
#include "SPI.h"                   //include SPI library

  int thermoDO = 50;            //define serial pin
  int thermoCLK = 52;              //define serial clock pin
  int CS;                       //define CS as int
  unsigned long time;              //define time as a long variable
  String stringone = "sensor ";    //define stringone as sensor
  String stringtwo = ",";       //define stringtwo as a comma
  
void setup() {  
  Serial.begin(9600); 
  delay(5000);           //initial delay
}
void loop(){
  int x=0;                                                                           //reset x to 0
  int myPins[16] = {15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 35, 36, 37, 38};  //define chip select array
   
for (x = 0; x < 16; x += 1){                                                         //start of first for loop
  CS = myPins[x];                                                                 //define chip select from array
  MAX6675 thermocouple(thermoCLK, CS, thermoDO);                                    //define first MAX6675 function
  float reading = (thermocouple.readCelsius());                                   //take thermocouple reading
  //Serial.print(CS);                                                               //print chip select pin
  time = millis()/1000 - 4;                                                       //take time reading
  String stringthree = stringone + (x+1) + stringtwo + time + stringtwo + reading;  //compile strings and increment x by 1
  Serial.println(stringthree);                                                    //print compiled string
  delay(1000);                                                                        //delay between sensor readings 
}

delay(10000);}                                                                   //delay between sets of readings

Hi,
Whoa.. Do you have 16 max6675 chips hooked up, each with their own thermocouple?

You need to slow down and get 2 or 4 working correctly.

You need to do the setup of the max6675 chips in Setup not Loop..

For each max6675, like:

MAX6675 thermocouple(thermoCLK, CS, thermoDO);

each Max6675 has to have it's own name, not just 'thermocouple'.

like:

MAX6675 thermocoupleA(CK_PIN, CS_PIN_A, SO_PIN);  // Create two Thermocouple objects with different chip selects
MAX6675 thermocoupleB(CK_PIN, CS_PIN_B, SO_PIN);

See this page for example:
http://arduino-info.wikispaces.com/Brick-Temperature-Thermocouple

AFTER you get the 6675's initialized and named/identified in Setup ONCE, then in loop you can start reading them individually...

Get 2 or 4 working first...

Let us know what happens...

Yeah I do currently have 16 hooked up(not working). I got 4 working first like you said to make sure it would work and then started going up from there. I got 8 hooked up next which seemed to work so I made the jump to 16.

I had it like you recommend initially with each MAX6675 in the setup but I figured it was easier to modify my code if I used an array to define the chip select pins as it looped as opposed to having many lines for defining and serial printing each thermocouple.

Would you recommend I go back to having each individually defined?

I did go back to my old code, took all but 4 out in a block comment and got them working properly. However when I implement the rest my problem of bad readings for the later sensors still persists. I have my code below as well as what the serial monitor shows.

#include "max6675.h"     //include libraries (https://github.com/adafruit/MAX6675-library)
#include "SPI.h"

int thermoDO = 50;        //define serial output pin
int thermoCLK = 52;       //define system clock pin

int thermoCS1 = 15;       //define chip select pins
int thermoCS2 =16;
int thermoCS3 = 17;
int thermoCS4 = 18;
/*
int thermoCS5 = 19;
int thermoCS6 = 20;
int thermoCS7 = 21;
int thermoCS8 = 22;
int thermoCS9 = 23;
int thermoCS10 = 24;
int thermoCS11 = 25;
int thermoCS12 = 26;                                        
int thermoCS13 = 35;
int thermoCS14 = 36;
int thermoCS15 = 37;
int thermoCS16 = 38;                                      
*/
MAX6675 thermocouple1(thermoCLK, thermoCS1, thermoDO);     //define MAX functions
MAX6675 thermocouple2(thermoCLK, thermoCS2, thermoDO);
MAX6675 thermocouple3(thermoCLK, thermoCS3, thermoDO);
MAX6675 thermocouple4(thermoCLK, thermoCS4, thermoDO);
/*
MAX6675 thermocouple5(thermoCLK, thermoCS5, thermoDO);
MAX6675 thermocouple6(thermoCLK, thermoCS6, thermoDO);
MAX6675 thermocouple7(thermoCLK, thermoCS7, thermoDO);
MAX6675 thermocouple8(thermoCLK, thermoCS8, thermoDO);
MAX6675 thermocouple9(thermoCLK, thermoCS9, thermoDO);
MAX6675 thermocouple10(thermoCLK, thermoCS10, thermoDO);
MAX6675 thermocouple11(thermoCLK, thermoCS11, thermoDO);
MAX6675 thermocouple12(thermoCLK, thermoCS12, thermoDO);
MAX6675 thermocouple13(thermoCLK, thermoCS13, thermoDO);
MAX6675 thermocouple14(thermoCLK, thermoCS14, thermoDO);
MAX6675 thermocouple15(thermoCLK, thermoCS15, thermoDO);
MAX6675 thermocouple16(thermoCLK, thermoCS16, thermoDO);
*/
int i = 1;                                                  //set data counter start point
unsigned long time;                                         //define time as a long variable
float thermoReading;


void setup() {
  Serial.begin(9600);                                        //set data rate
  delay(10000);                                              //initial delay
}

void loop() {

  Serial.print("Data Set #");                               //print data set label
  Serial.println(i);                                        //print data set numer


time = millis()/1000;                                       //take time reading
  Serial.print("sensor 1,");                                //print sensor label
  Serial.print(time);                                       //print time
  Serial.print(",");                                        //print comma
  thermoReading = thermocouple1.readCelsius();              //take thermocouple reading
  Serial.println(thermoReading);                            //print thermocouple reading
  delay(100);                                               //delay between readings

time = millis()/1000;
  Serial.print("sensor 2,");
  Serial.print(time);
  Serial.print(",");
  thermoReading = thermocouple2.readCelsius();           
  Serial.println(thermoReading);
  delay(100);

time = millis()/1000;
  Serial.print("sensor 3,");
  Serial.print(time);
  Serial.print(",");
  thermoReading = thermocouple3.readCelsius();            
  Serial.println(thermoReading);
  delay(100);

time = millis()/1000;
  Serial.print("sensor 4,");
  Serial.print(time);
  Serial.print(",");
  thermoReading = thermocouple4.readCelsius();             
  Serial.println(thermoReading);
  delay(100);
/*
time = millis()/1000;
  Serial.print("sensor 5,");
  Serial.print(time);
  Serial.print(",");
  thermoReading = thermocouple5.readCelsius();             
  Serial.println(thermoReading);
  delay(100);

time = millis()/1000;
  Serial.print("sensor 6,");
  Serial.print(time);
  Serial.print(",");
  thermoReading = thermocouple6.readCelsius();             
  Serial.println(thermoReading);
  delay(100);

time = millis()/1000;
  Serial.print("sensor 7,");
  Serial.print(time);
  Serial.print(",");
  thermoReading = thermocouple7.readCelsius();                                               
  Serial.println(thermoReading);
  delay(100);

time = millis()/1000;
  Serial.print("sensor 8,");
  Serial.print(time);
  Serial.print(",");
  thermoReading = thermocouple8.readCelsius();              
  Serial.println(thermoReading);
  delay(100);

time = millis()/1000;
  Serial.print("sensor 9,");
  Serial.print(time);
  Serial.print(",");
  thermoReading = thermocouple9.readCelsius();              
  Serial.println(thermoReading);
  delay(100);

time = millis()/1000;
  Serial.print("sensor 10,");
  Serial.print(time);
  Serial.print(",");
  thermoReading = thermocouple10.readCelsius();              
  Serial.println(thermoReading);
  delay(100);

time = millis()/1000;
  Serial.print("sensor 11,");
  Serial.print(time);
  Serial.print(",");
  thermoReading = thermocouple11.readCelsius();              
  Serial.println(thermoReading);
  delay(100);

time = millis()/1000;
  Serial.print("sensor 12,");
  Serial.print(time);
  Serial.print(",");
  thermoReading = thermocouple12.readCelsius();              
  Serial.println(thermoReading);
  delay(50);

time = millis()/1000;
  Serial.print("sensor 13,");
  Serial.print(time);
  Serial.print(",");
  thermoReading = thermocouple13.readCelsius();             
  Serial.println(thermoReading);
  delay(50);

time = millis()/1000;
  Serial.print("sensor 14,");
  Serial.print(time);
  Serial.print(",");
  thermoReading = thermocouple14.readCelsius();              
  Serial.println(thermoReading);
  delay(50);

time = millis()/1000;
  Serial.print("sensor 15,");
  Serial.print(time);
  Serial.print(",");
  thermoReading = thermocouple15.readCelsius();             
  Serial.println(thermoReading);
  delay(50);

time = millis()/1000;
  Serial.print("sensor 16,");
  Serial.print(time);
  Serial.print(",");
  thermoReading = thermocouple16.readCelsius();                                                     
  Serial.println(thermoReading);
*/
  i += 1;                                                 //adding to data set counter (add 1)

  delay(10000);                                           //set time delay between set readings
}

Serial monitor with only 4

Data Set #1
sensor 1,9,24.75
sensor 2,10,24.50
sensor 3,10,24.75
sensor 4,10,23.75
Data Set #2
sensor 1,20,24.75
sensor 2,20,24.25
sensor 3,20,25.00
sensor 4,20,23.75

Serial monitor with 16

Data Set #3
sensor 1,33,25.25
sensor 2,33,24.25
sensor 3,33,25.25
sensor 4,34,24.50
sensor 5,34,25.50
sensor 6,34,24.50
sensor 7,34,25.75
sensor 8,34,16.00
sensor 9,34,15.00
sensor 10,34,16.00
sensor 11,35,16.00
sensor 12,35,14.00
sensor 13,35,16.00
sensor 14,35,15.00
sensor 15,35,16.00
sensor 16,35,15.00

Bump since I still haven't been able to solve this issue. Any help would be appreciated.

I found the MAX31855 (similar to the MAX6675) was very sensitive to radio interference. For my application, this was unacceptable. When any radio transmitted nearby, I got negative Kelvins.

I ended up switching to the MAX31865 which uses RTD sensing elements. That was totally immune to interference.

Also consider using the DS18B20 if your application can work within the temperature range of that chip. It's much easier to wire up and use.

Hello my fellow arduino enthusiasts,

I'm pursuing a similar project as kimball75. In the hopes of you reading this (or anyone with any kind of help or even a solution :wink: ) here is my situation:

First of all im quite new to Arduinos.
I want to hook at least 9 (well one more than 8 :wink: ) K-type thermocouples to my arduino nano and then send the measurement via bluetooth to a windows computer, read them out with python and visualize them in realt time. I managed to have the sending, receiving, visualizing part going for thermistors, but now i have to switch to K-type because of their high temperature range.

Can you supply me with any kind of help in setting them up propperly, physically and software wise?
How do i connect (1,2,9) to one Arduino? Do i need a MAX6675 for each of them? Do i need another element to connect the MAX to the Arduino?
What does the code look like i need to set the setup up?

I am very thankful for any kind of advise :slight_smile: