Help with RTC

Hello,

I am having trouble with my code for the monitoring and logging to SD of 4 pt100 RTD temperature sensors. I am using an UNO with a seeedlab v4.3 SD card and the adifruit DS1307 RTC.

The problem:

Upload the code, no errors. Open the serial monitor, nothing, blank, no response.

When I pull the RTC from the SD card (I have is plugged directly into the SD shield with pins A2 and A3 codded to give it power and ground the serial monitor instatntly responds as it should. Without the time stamp of course. Then if i plug the RTC back in all is perfect.

What gives?? something in the Code??

RTDsJTP.ino (6.47 KB)

// This sketch is for temperature monitoring of four PT100 RTD sensors with SD logging as well as time stamp 

// For Arduino UNO, SeeedLab v4.3 SD shield, and Adafruit DS1307 Real Time Clock (RTC)
// Use SAVING_TIME to change the SD saving interval
//The device address (0x68) of DS1307 RTC as well as transmission calls are included in the RTC library (RTClib.h).

#include <Adafruit_MAX31865.h>                                        // RTD Amplifier
#include <SPI.h>                                                      // SPI devices (e.g., SD shield)
#include <SD.h>                                                      // SD
#include <Wire.h>                                                    // I2C devices (e.g., LCD and RTC)
#include <RTClib.h>                                                  // Real-time clock 
#include <elapsedMillis.h>                                            // Timer

RTC_DS1307 RTC;

#define SAVING_TIME 3000                                            // Every 5 minutes for SD data logging (in msec)
elapsedMillis timeElapsed;                                            // Global variable used to determine when to save the data to the SD card
#define RREF 430.0                                                    // The value of the Rref resistor on the RTD. Use 430.0!                                                               
                                                                     
                                                                      // Use software SPI: CS, DI, DO, CLK (same DI,DO,CLK -> use CS to control communication
Adafruit_MAX31865 max1 = Adafruit_MAX31865(6,7,8,9);                  // Pin 6 is HO
Adafruit_MAX31865 max2 = Adafruit_MAX31865(5,7,8,9);                  // Pin 5 is CI
Adafruit_MAX31865 max3 = Adafruit_MAX31865(4,7,8,9);                  // Pin 4 is CO
Adafruit_MAX31865 max4 = Adafruit_MAX31865(3,7,8,9);                  // Pin 3 is HI

void setup() {
                           
  Serial.begin(9600);                                                // Open the serial port to print data on the Serial Monitor (Data: 8 bits, Parity: None, Stop bit: 1 bit)
  RTC.begin();                                                        // Initialization of real-time clock
  RTC.adjust(DateTime(DATE, TIME));                          // Sets the RTC to the date & time when this sketch was compiled
 
  pinMode(A2, OUTPUT);                                                // For using RTC driectly on UNO board
  digitalWrite(A2, LOW);
  pinMode(A3, OUTPUT);                                                // For using RTC driectly on UNO board
  digitalWrite(A3, HIGH);

Serial.print("Initializing SD card... ");                            // See if the card is present and can be initialized
  if (!SD.begin(4)) {                                                // SS pin for the SeeedLab v4.3 SD Shield: CS: 4, DI: 11, DO: 12, CLK: 13 (reserved for SD card)
    Serial.println("Card failed, or not present");
    return;                                                 
  }
Serial.println(" Card Good To Go :slight_smile: ");   
 
  max1.begin(MAX31865_3WIRE);                                        // Set to 2WIRE or 4WIRE as necessary
  max2.begin(MAX31865_3WIRE);
  max3.begin(MAX31865_3WIRE);
  max4.begin(MAX31865_3WIRE);

}

void loop(){
 
  DateTime now = RTC.now();                                          // Read the current date and time                                                                     
                                                                                                                                                                                                                                                                                                                       
  float HI = max4.temperature(100, RREF);                            // Call the function in the amplifier library to calculate the RTD temperature (in degree C)                                                                     
  float HO = max1.temperature(100, RREF);                                                                                                                                                                                                     
  float CI = max2.temperature(100, RREF);                                                                                                                                                                                                               
  float CO = max3.temperature(100, RREF);
                                                               
    if (timeElapsed >= SAVING_TIME) {                                      // Establishes data logging timing
      File dataFile = SD.open("templog.txt", FILE_WRITE);                  // Opens data file if available or creates a new one
      dataFile.print(now.year(), DEC);
      dataFile.print('/');
      dataFile.print(now.month(), DEC);
      dataFile.print('/');
      dataFile.print(now.day(), DEC);
      dataFile.print(' ');
      dataFile.print(now.hour(), DEC);
      dataFile.print(':');
      dataFile.print(now.minute(), DEC);
      dataFile.print(':');
      dataFile.print(now.second(), DEC);       
      dataFile.print("  ");                   
      dataFile.print("HI, HO, CI, CO = ");
      dataFile.print(HI);
      dataFile.print(", ");
      dataFile.print(HO);
      dataFile.print(", ");
      dataFile.print(CI);
      dataFile.print(", ");
      dataFile.println(CO);
      dataFile.close();

timeElapsed = 0;                                                  // Resets timer
    }
                                                                       
  Serial.print(now.year(), DEC);                                      // Print to the Serial Monitor
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.print(now.day(), DEC);
  Serial.print(' ');
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  Serial.print(now.second(), DEC);       
  Serial.print("  ");                         
  Serial.print("HI, HO, CI, CO = ");
  Serial.print(HI);
  Serial.print(", ");
  Serial.print(HO);
  Serial.print(", ");
  Serial.print(CI);
  Serial.print(", ");
  Serial.println(CO);
                                                                     
  delay(5000);                                                        // Time delay
}