Problem with multiple MAX6675 thermocouple

Hi, to everyone!

Maybe someone could help me solve my problem. I have project where I need 6 K-type thermocouples. I choosed MAX6675 digital converter. I Attached all 6 converters to my Arduino Mega 2560, but when I start my sketch Arduino reads only 0.00 C degrees. I’m using array for all thermocouples and switching CS pin from LOW to HIGH, also I was trying switch CS pin from HIGH to LOW with no luck.

#include "max6675.h"

const int tcSO[]  = {50, 50, 50, 50, 50, 50};
const int tcCS[]  = {22, 28, 29, 23, 34, 35};
const int tcCLK[] = {52, 52, 52, 52, 52, 52};
const int tcVCC[] = {24, 30, 31, 25, 36, 37};
const int tcGND[] = {26, 32, 33, 27, 38, 39};


MAX6675 thermocouple[] = {
  MAX6675(tcCLK[1], tcCS[1], tcSO[1]),
  MAX6675(tcCLK[2], tcCS[2], tcSO[2]),
  MAX6675(tcCLK[3], tcCS[3], tcSO[3]),
  MAX6675(tcCLK[4], tcCS[4], tcSO[4]),
  MAX6675(tcCLK[5], tcCS[5], tcSO[5]), 
  MAX6675(tcCLK[6], tcCS[6], tcSO[6]), 
};

void setup() {
  Serial.begin(9600);
    delay(1000);
   
    
  for(int tc = 1; tc <= 6; tc++){
    digitalWrite(tcCS[tc], LOW);  
    delay(1000);
    digitalWrite(tcGND[tc], LOW);  
    delay(1000);
    digitalWrite(tcVCC[tc], HIGH);  
    delay(1000);    
  }

  for(int tc = 1; tc <= 6; tc++){
    digitalWrite(tcCS[tc], HIGH);
    delay(1000);  
    Serial.println(thermocouple[tc].readCelsius());
    digitalWrite(tcCS[tc], LOW);    
    delay(1000);
  }  
    
  

}

void loop() {
  // put your main code here, to run repeatedly:

}

Any help will be appreciated!

Hi, To start with, the array index starts at zero.

So 0..5 used in your case.

Try after that!

Here's code I used that has 3 MAX6675's: https://arduinoinfo.mywikis.net/wiki/Project-GlassKilnController-Code

Hi,

I've changed both my "for" loops for 0..5, but that didn't solved my problem, same zero readings. If I'm trying setup only one thermocouple, then everything is fine.

Any reason why you have connected VCC and ground to digital pins?

You're activating all modules (setting all the CS LOW), and then try to read one module? You're supposed to activate ONE, read it, disable it, activate the next one... Leo..

Only reason why I connected VCC and GND to digital pins is, that for my opinion it is very comfortable to manage them.

As I wrote I tried different ways, also when I deactivate all modules result was same - Zero readings.

#include "max6675.h"

const int tcSO[]  = {50};
const int tcCS[]  = {22};
const int tcCLK[] = {52};
const int tcVCC[] = {24};
const int tcGND[] = {26};


MAX6675 thermocouple[] = {
  MAX6675(tcCLK[1], tcCS[1], tcSO[1]),
  MAX6675(tcCLK[2], tcCS[2], tcSO[2]),
  MAX6675(tcCLK[3], tcCS[3], tcSO[3]),
  MAX6675(tcCLK[4], tcCS[4], tcSO[4]),
  MAX6675(tcCLK[5], tcCS[5], tcSO[5]), 
  MAX6675(tcCLK[6], tcCS[6], tcSO[6]), 
};

void setup() {
  Serial.begin(9600);
    delay(1000);
   
    
  for(int tc = 0; tc <= 5; tc++){
    digitalWrite(tcCS[tc], HIGH);  
    delay(1000);
    digitalWrite(tcGND[tc], LOW);  
    delay(1000);
    digitalWrite(tcVCC[tc], HIGH);  
    delay(1000);    
  }

  Serial.println(thermocouple[0].readCelsius());

  for(int tc = 0; tc <= 5; tc++){
    digitalWrite(tcCS[tc], LOW);
    delay(1000);  
    Serial.println(thermocouple[tc].readCelsius());
    digitalWrite(tcCS[tc], HIGH);    
    delay(1000);
  }  
    
  

}

void loop() {

}

When I’m turning off power for 5 sensors, then sketch is working fine with one sensor, could it be some issue with VCC and GND pins?

#include "max6675.h"
const int tcCLK = 52;
const int tcSO = 50;
int tcCS[]  = {22, 23, 28, 29, 34, 35};
int tcVCC[] = {24, 25, 30, 31, 36, 37};
int tcGND[] = {26, 27, 32, 33, 38, 39};

MAX6675 thermocouple[] = {
                          MAX6675(tcCLK, tcCS[0], tcSO),
                          MAX6675(tcCLK, tcCS[1], tcSO),
                          MAX6675(tcCLK, tcCS[3], tcSO),
                          MAX6675(tcCLK, tcCS[4], tcSO),
                          MAX6675(tcCLK, tcCS[5], tcSO), 
                          MAX6675(tcCLK, tcCS[6], tcSO), 
};


void setup() {
   
  Serial.begin(9600);
  delay(500);
  pinMode(24, OUTPUT); digitalWrite(24, HIGH);
  pinMode(26, OUTPUT); digitalWrite(26, LOW);

  //pinMode(25, OUTPUT); digitalWrite(25, HIGH);
  //pinMode(27, OUTPUT); digitalWrite(27, LOW);

  //pinMode(30, OUTPUT); digitalWrite(30, HIGH);
  //pinMode(32, OUTPUT); digitalWrite(32, LOW);

  //pinMode(tcVCC[3], OUTPUT); digitalWrite(tcVCC[3], HIGH);
  //pinMode(tcGND[3], OUTPUT); digitalWrite(tcGND[3], LOW);

  //pinMode(tcVCC[4], OUTPUT); digitalWrite(tcVCC[4], HIGH);
  //pinMode(tcGND[4], OUTPUT); digitalWrite(tcGND[4], LOW);

  //pinMode(tcVCC[5], OUTPUT); digitalWrite(tcVCC[5], HIGH);
  //pinMode(tcGND[5], OUTPUT); digitalWrite(tcGND[5], LOW);


  for (int pin = 0; pin<=5; pin++){
      digitalWrite(tcCS[pin], LOW);
  }

  for (int cs = 0; cs<=5; cs++){
  digitalWrite(tcCS[cs], HIGH);
  delay(500);
  Serial.println(thermocouple[cs].readCelsius());
  delay(500);
  digitalWrite(tcCS[cs], LOW);
  delay(500);
 
  }
}

void loop() {

}

Thanks for all! I solved my problem!

I’ll never use digital pins for powering up my sensors. I guess that powering up sensors from digital pins is making some interference and thats why I was getting zero readings. Attached VCC to +5V and GND to GND pins now everything is fine.

#include "max6675.h"
const int tcCLK = 52;
const int tcSO = 50;
int tcCS[]  = {22, 23, 24, 25, 26, 27};

MAX6675 thermocouple[] = {
                          MAX6675(tcCLK, tcCS[0], tcSO),
                          MAX6675(tcCLK, tcCS[1], tcSO),
                          MAX6675(tcCLK, tcCS[2], tcSO),
                          MAX6675(tcCLK, tcCS[3], tcSO),
                          MAX6675(tcCLK, tcCS[4], tcSO), 
                          MAX6675(tcCLK, tcCS[5], tcSO), 
};


void setup() {
   
  Serial.begin(9600);
  delay(500);
  
  for (int pin = 0; pin<=5; pin++){
      digitalWrite(tcCS[pin], LOW);
  }
}

void loop() {
int pin = 1;
for (int cs = 0; cs<=5; cs++){
  digitalWrite(tcCS[cs], LOW);
  delay(50);
  Serial.print("temperatūras devējs Nr. ");
  Serial.print(pin);
  Serial.print(" ");
  ++pin;
  Serial.println(thermocouple[cs].readCelsius());
  digitalWrite(tcCS[cs], HIGH);
  delay(500);
 
  }
}