I want to connect 4 MAX6675 thermocouple to Arduino. MAX 6675 description.

It comes with its own Arduino library. library link.

I tested the example code for one sensor and it works perfectly. Now I want to connect all the four sensors to Arduino using minimum GPIO pins possible.

I connected - (for 2 sensors only for initial testing):

D7 -> clk (slave 1) ->clk (slave 2)
D3 -> so (slave 1) ->so (slave 2)
D4 -> cs (slave 1)
D5 -> cs (slave 2)

My code (I modified the original example code a bit):

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

#include "max6675.h"

int thermoCLK = 7;
int thermoDO = 3;
int thermoCS = 4;
int thermoCS2 = 5;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
MAX6675 thermocouple2(thermoCLK, thermoCS2, thermoDO);

void setup() {
  Serial.println("MAX6675 test");
  // wait for MAX chip to stabilize

void loop() {
  // basic readout test, just print the current temp
  Serial.print("C = ");
  Serial.print("F = ");
  Serial.print("C 2= ");
  Serial.print("F 2= ");

I am able to read only one sensor information correctly. The other output is nan. Am I wiring the circuit wrong or is my code incorrect or both?

  • 1
    I'd not use that library. Instead I'd one that uses SPI properly. Then you use just N+2 pins. Or since it's so simple to use anyway, just use SPI directly.
    – Majenko
    Apr 17, 2017 at 14:54
  • The above program will not run as it is as there is a syntax error. You have readCelsius in the beginning and readCelcius later on, all references should be readCelsius. Best regards, Phil.
    – Bonzo
    Oct 6, 2018 at 21:49
  • Why would you not use pin 19 for SCK and pin 18 for MISO to keep the digital pins free? Could you please comment on what each line does in that code, just trying to learn and understand as I want to use 4 thermocouple and then write to 6 relay outputs. Oct 10, 2018 at 6:49

1 Answer 1


First off ditch that library. It's completely pointless and actually makes things harder.

Secondly connect your sensors to the SPI pins, selecting a new CS pin for each sensor.

  • Arduino SCK (pin 13) to all the SCK pins.
  • Arduino MISO (pin 12) to all the SO pins.
  • Individual GPIO pins to individual CS pins (use pin 10 for one of them).

Then just use a simple function to read the data using the SPI library (adapted from the library you link to). For instance with CS on 10 an 9:

#include <SPI.h>

double readCelsius(uint8_t cs) {
    uint16_t v;

    digitalWrite(cs, LOW);
    v = SPI.transfer(0x00);
    v <<= 8;
    v |= SPI.transfer(0x00);
    digitalWrite(cs, HIGH);

    if (v & 0x4) {
        // uh oh, no thermocouple attached!
        return NAN; 

    v >>= 3;

    return v*0.25;

void setup() {
    pinMode(10, OUTPUT);
    pinMode(9, OUTPUT);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);


void loop() {
    Serial.print(" ");
  • Shouldn't the above code also refer to the SCK and MISO pins?
    – uzadude
    Dec 12, 2021 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.