Initializing SD card disturbs serial connection with MAX6675 Module

I am trying to collect temperature data from a HiLetgo MAX6675 Module and write it to a HiLetgo 3-01-0038 Micro SD Card Reader. I have duplicated the breadboard setup with second set of components with the same result. The temperature module works until I initialize the SD card reader, then the temperature module does not work. I get the same result if I remove all of the digitalWrite functions. In addition, the chip select pins do not appear to be working the way I thought they should.

#include "max6675.h" // max6675.h library
#include <SD.h>
#include <SPI.h>

int soPin = 12;// SO=Serial Out
int tempcsPin = 10;// CS = chip select CS pin for temp sensor
int sckPin = 13;// SCK = Serial Clock pin
int sdcsPin = 4; // CS pin for SD card

MAX6675 thermocouple(sckPin, tempcsPin, soPin);// create instance object of MAX6675

void setup() {
  pinMode(sdcsPin, OUTPUT);
  Serial.begin(9600); // initialize serial monitor with 9600 baud

  digitalWrite(tempcsPin, HIGH);  // This should be LOW but it still works HIGH??
  Serial.print("1st Temp Reading = "); 
  Serial.println(thermocouple.readFahrenheit()); //1st temp reading
  digitalWrite(tempcsPin, HIGH);   // Take the chip select high to de-select 

  // SD Card Initialization
  if (SD.begin(sdcsPin))
    Serial.println("SD card is ready to use.");
  } else
    Serial.println("SD card initialization failed");
  digitalWrite(sdcsPin, HIGH);   // Take the chip select high to de-select

  digitalWrite(tempcsPin, LOW);
  Serial.print("2nd Temp Reading = "); 
  Serial.println(thermocouple.readFahrenheit()); //2nd temp reading 
  digitalWrite(tempcsPin, HIGH);

  // SD Card Initialization a second time works
  digitalWrite(sdcsPin, HIGH); // This should be LOW but it still works HIGH??
  if (SD.begin(sdcsPin))
    Serial.println("SD card is ready to use.");
  } else
    Serial.println("SD card initialization failed");


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


This is the output from the serial monitor:

1st Temp Reading = 71.60
SD card is ready to use.
2nd Temp Reading = 32.00
SD card is ready to use.

Any help would be greatly appreciated!

Electrical diagram.jpg

I would suggest getting the SD card alone working.

Thanks for the feedback! Both the SD card and the temperature sensor work alone. My problem is that I can not get an accurate reading from the temp module after the SD card module is initialized. The temperature sensor behaves as if the SCK output is not available.

You'll want to Google that.
I have read about devices which don't play nice.


You declare the pinMode(sdcsPin, OUTPUT) but not the tempcsPin?

I believe the problem lies with the microSD card module. The design of this module runs the lines through an x125 chip to translate from 5V down to the 3.3V needed by all SD cards. It does that for the CS, CLK and MOSI lines coming from the Arduino, but it also does it for the MISO line output from the SD card, which really doesn’t need to be translated at all.

The problem is that the 125 gate used for MISO is always On. The SD card is supposed to release the MISO line when its CS is de-asserted so that other SPI parts can use that line. But since the 125 gate is always enabled even when CS isn’t asserted, it interferes with the output line of the MAX module. The Enable pin for the 125 gate is tied to ground, which means it’s always on. It should actually be tied to CS so it would turn on, and off, at the right times. This is not a problem if the SD module is the only SPI device, but messes things up when there are two or more.

I’ll attach a schematic showing the problem and one possible fix, which is to simply disconnect the gate output from the header pin, and instead connect the SD card’s MISO pin directly to the header pin (the SD card knows how to behave properly, and will do so if the 125 doesn’t interfere).

I have to say this is my best guess. But all microSD modules I’ve ever seen have this problem, so I think it’s pretty likely to be the explanation, particularly if both modules work alone.