SD card data logging with EVAL-CN0391-ARDZ shield via SPI?

I bought a Eval-CN3091-ARDZI and tried it out with my Arduino Uno board with the sample code without any issue.     My SD card (integrated into a TFT LCD shied) works fine with the Uno borad.  But the SD card stopped working when stack the TFT on top of the Eval-CN3091-ARDZ shield.  It works when place the shunt to 3 and 4 position (instead of 1 and 2) and I code the Slave Select pin to 8 (instead of the default 10).   

The issue I am having now is that I can not have CN3091 board and my SD card communicating via SPI  in a way so that  log themocouple readings are logged in my SD card.  The AD7124 user guide does clearly state which shunt position is corresponding to which slave Select Pin in Arduino board.

Any thought on why and any possible solutions?

#include <SPI.h>
#include "CN0391.h"
#include "Communication.h"
// include the SD library:
#include <SD.h>

// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;
File dataFile;
// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = 8;

//#define SS 10 //ss

void setup() {
     while (!Serial) {
      ; // wait for serial port to connect. Needed for Leonardo only
pinMode(4, OUTPUT);
pinMode(10, OUTPUT);

    Serial.print("Initializing SD card...");
    // make sure that the default chip select pin is set to
    // output, even if you don't use it:
    pinMode(SS, OUTPUT);

    // see if the card is present and can be initialized:
    if (!SD.begin(chipSelect)) {
      Serial.println("Card failed, or not present");
      // don't do anything more:
      while (1) ;
    Serial.println("card initialized.");


Serial.println("\nThermo Couple Starts: ");
digitalWrite(8,HIGH); //disable device

//pinMode(CS_PIN, OUTPUT);
pinMode(SS, OUTPUT);
     SPI.setDataMode(SPI_MODE3); //CPHA = CPOL = 1    MODE = 3

   Serial.println(F("RTD channel calibration completed!"));
   Serial.println(F("Calibration for RTD channel is disabled."));

   Serial.println(F("TC channel calibration completed!"));
   Serial.println(F("Calibration for TC channel is disabled."));


void loop() {


add sketch
[edited by: ystan at 8:12 PM (GMT 0) on 28 Feb 2019]
  • 0
    •  Analog Employees 
    on Mar 7, 2019 10:26 AM over 1 year ago


    I am moving this thread to Reference Circuits as they may have better understanding regarding the circuit board and configuration. If you find any issue specific to AD7124, feel free to post it again to Precision ADC.   



  • +1
    •  Analog Employees 
    on Mar 8, 2019 7:50 PM over 1 year ago


    So it makes sense that the boards stacked on top of each other don't work initially because they share the same chip select pin.  So you did the correct thing in moving the jumper position on the EVAL-CN0391-ARDZ (thats why we added that flexibility).

    The problem you are having now is that you need to read SPI data from the CN0391 onto the Arduino Uno, and then you need to write SPI data back out to the SD card.  You are going to need to create another variable or array to capture the incoming temperature data, and store that on the Arduino.  Once you have x number of samples, you'll want to stop reading the CN0391 and then write those temperature values to the SD card.

    You can only address one SPI device at a time so this is why you are currently having issues.

    Good Luck.