Connecting multiple k-type thermocouples via MAX31855 to an Arduino

Hi, I am a beginner to Arduino and I am attempting to connect 6 k-type (ungrounded) thermocouples each connected via a MAX31855 amplifier to an Arduino Mega, in order to get 6 individual temperature readings when the thermocouples are introduced to an environment with heated air. The code, as will be shared below, is an adaptation of the code provided by Adafruit from their MAX31855 library, and is currently written for 3 thermocouples on the Arduino IDE. The labelled circuit schematic shows how I have connected three k-type thermocouples and I plan to extend this for six. I have 'daisy-chained' the DO and CLK cables and used individual cables for the CS for each MAX31855.

I have the following queries regarding this project:

  • Is there a way to make the code more efficient (and do I really need the void setup() function)? Can changing the Baud rate from 9600 to something else be more efficient?
  • The temperature data outputted works well when slowly introducing heat into the system, like dipping the thermocouples into boiling water. But when introducing a flame via a lighter to the tip of the thermocouple, the reading jumps from 30 to 300 to 34 and back to 275 - as an example, as opposed to sustaining a consistent reading. Is this normal, or is there a way to address this issue?
  • Any other considerations I should make for this project?

Appreciate any guidance - and feedback if I have made an incorrect forum post. Cheers.

#include <SPI.h>
#include "Adafruit_MAX31855.h"

#define MAXDO   12 // Data Output cable
#define MAXCLK  13 // CLock Cable
#define MAXCS1   10 // Chip Select #1
#define MAXCS2   9 // Chip Select #2
#define MAXCS3   8 // Chip Select #3
/*
#define MAXCS4   7 // Chip Select #4
#define MAXCS5   6 // Chip Select #5
#define MAXCS6   5 // Chip Select #6
*/

// initialize the Thermocouple
Adafruit_MAX31855 thermocouple1(MAXCLK, MAXCS1, MAXDO);
Adafruit_MAX31855 thermocouple2(MAXCLK, MAXCS2, MAXDO);
Adafruit_MAX31855 thermocouple3(MAXCLK, MAXCS3, MAXDO);
/*
Adafruit_MAX31855 thermocouple4(MAXCLK, MAXCS4, MAXDO);
Adafruit_MAX31855 thermocouple5(MAXCLK, MAXCS5, MAXDO);
Adafruit_MAX31855 thermocouple6(MAXCLK, MAXCS6, MAXDO);
*/

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

while (!Serial) delay(1); // wait for Serial on Leonardo/Zero, etc

  Serial.println("MAX31855 test_1");
  // wait for MAX chip to stabilize
  delay(500);
  Serial.print("Initializing sensor_1...");
  if (!thermocouple1.begin()) {
    Serial.println("ERROR_Sensor_1");
    while (1) delay(10);
  }

  Serial.println("DONE_Sensor_1");
}

void loop() {

   double c1 = thermocouple1.readCelsius();
   if (isnan(c1)) {
     Serial.println("Thermocouple_1 fault(s) detected!");
     uint8_t e = thermocouple1.readError();
     if (e & MAX31855_FAULT_OPEN) Serial.println("FAULT: Thermocouple_1 is open - no connections.");
     if (e & MAX31855_FAULT_SHORT_GND) Serial.println("FAULT: Thermocouple_1 is short-circuited to GND.");
     if (e & MAX31855_FAULT_SHORT_VCC) Serial.println("FAULT: Thermocouple_1 is short-circuited to VCC.");
   } else {
     Serial.print("C_1 = ");
     Serial.println(c1);
   }
 
   double c2 = thermocouple2.readCelsius();
   if (isnan(c2)) {
     Serial.println("Thermocouple_2 fault(s)_1 detected!");
     uint8_t e2 = thermocouple2.readError();
     if (e2 & MAX31855_FAULT_OPEN) Serial.println("FAULT: Thermocouple_2 is open - no connections.");
     if (e2 & MAX31855_FAULT_SHORT_GND) Serial.println("FAULT: Thermocouple_2 is short-circuited to GND.");
     if (e2 & MAX31855_FAULT_SHORT_VCC) Serial.println("FAULT: Thermocouple_2 is short-circuited to VCC.");
   } else {
     Serial.print("C_2 = ");
     Serial.println(c2);
   }

  double c3 = thermocouple3.readCelsius();
   if (isnan(c3)) {
     Serial.println("Thermocouple_3 fault(s) detected!");
     uint8_t e3 = thermocouple3.readError();
     if (e3 & MAX31855_FAULT_OPEN) Serial.println("FAULT: Thermocouple_3 is open - no connections.");
     if (e3 & MAX31855_FAULT_SHORT_GND) Serial.println("FAULT: Thermocouple_3 is short-circuited to GND.");
     if (e3 & MAX31855_FAULT_SHORT_VCC) Serial.println("FAULT: Thermocouple_3 is short-circuited to VCC.");
   } else {
     Serial.print("C_3 = ");
     Serial.println(c3);
   }

   delay(500);
}

Yes. A function named setup() must be present, but is not required to contain any code. It is very handy for doing one time operations, like setting up the serial Baud rate, pin modes, etc.

Can changing the Baud rate from 9600 to something else be more efficient?

115200 is a popular choice.

the reading jumps from 30 to 300 to 34 and back to 275

Sounds like you have an intermittent connection. Check continuity with your multimeter.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.