Data logging using thermocouple MAX6675

I want to log data reading from thermocouple to SD card. As thermocouple and SD both run on SPI connection I tried making one SS pin HIGH and other LOW but I am encounter an issue that when I include SD.begin(); the thermocouple stops giving out reading. Does anyone know how to fix this problem.

#include <SPI.h>
#include <SD.h>
#define cardSelect 4
#include "max6675.h"
File logFile;
char fileName[] = "00THERMO00.csv";

int thermoDO = 14;
int thermoCS = 16;
int thermoCLK = 15;

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);

void setup() {
  Serial.begin(9600);
  digitalWrite(thermoCS,HIGH);
  digitalWrite(cardSelect,HIGH);

  SD.begin(cardSelect);
  while (SD.exists(fileName)) {
    if (fileName[1] != '9') {
      fileName[1]++;
    } 
    else if (fileName[0] != '9') {
      fileName[1] = '0';
      fileName[0]++;
    }
  }
}
void loop() {
  // basic readout test, just print the current temp
 digitalWrite(thermoCS, LOW);
 digitalWrite(cardSelect,HIGH); 
  Serial.print("C = "); 
  digitalRead(thermocouple.readCelsius());
 Serial.println(thermocouple.readCelsius());

 digitalWrite(thermoCS, HIGH);
 digitalWrite(cardSelect,LOW);

File logFile = SD.open(fileName, FILE_WRITE);
logFile.print("C=");
logFile.println(thermocouple.readCelsius());
logFile.close();

  // For the MAX6675 to update, you must delay AT LEAST 250ms between reads!
  delay(1000);
}

Use an SS pin for each device.

yes I have done that in code SS pin for thermocouple is 16 and SD card is 4

what Arduino are you using?
upload a schematic showing how you have wired and powered the modules?

It's adalogger feather ATmega32u4 connections are pretty straight forward I have connected MOSI, MISO, CLK of thermocouple sensor to the board with 3.3v VDD and GND. The SDcard is inbuilt in the board and chip select pin for it is pin4.
The thermocouple is reading data when SD.begin is initialized.

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