/*************************************************** Project to data log 4 ThermoCouple channels onto an SD card Using Adafruit MAX31855 Breakout Boards for the TC's and an SD Card Sheild Code for Arduino MEGA 2560 /****************************************************/ #include #include #include #include RTC_DS1307 RTC; // Real Time Clock Object DateTime now; // Link Date & Time to Current PC time SdFat sd; // SD Card Object SdFile logfile; // SD Card Logfile Object //Setup SPI Pins int ChipSelect1 = 4; //Thermocouple #1 int ChipSelect2 = 5; //Thermocouple #2 int ChipSelect3 = 6; //Thermocouple #3 int ChipSelect4 = 7; //Thermocouple #4 int ChipSelect5 = 8; //SD Card Shield int SlaveIn = 51; //MOSI set by default int SlaveOut = 50; //MISO set by default int SCLK = 52; //set by default MAX31855 thermocouple1(SlaveOut, ChipSelect1, SCLK); MAX31855 thermocouple2(SlaveOut, ChipSelect2, SCLK); MAX31855 thermocouple3(SlaveOut, ChipSelect3, SCLK); MAX31855 thermocouple4(SlaveOut, ChipSelect4, SCLK); void setup() { Serial.begin(9600); while (!Serial) {} // wait for input Serial.println("Waiting...."); Serial.println("Type any character to start"); while (Serial.read() <= 0) {} delay(500); // Allow MAX31855 Amps to Start Up Wire.begin(); RTC.begin(); RTC.adjust(DateTime(__DATE__, __TIME__));// Reset real-time clock to current date & time Serial.println("Startup Complete"); delay(500); // Initialize SdFat or print a detailed error message and halt // Use half speed like the native library. // change to SPI_FULL_SPEED for more performance. // Serial.println("Initalizing SD Card"); // delay(400); // if (!sd.begin(ChipSelect5, SPI_HALF_SPEED) { // Serial.println("SD Card error"); // } else { // Serial.println("SD Card Initialized"); // } // delay(400); // Serial.println("Starting Program Loop"); } void loop() { double c1 = thermocouple1.readThermocouple(CELSIUS); double c2 = thermocouple2.readThermocouple(CELSIUS); double c3 = thermocouple3.readThermocouple(CELSIUS); double c4 = thermocouple4.readThermocouple(CELSIUS); DateTime now = RTC.now(); Serial.println(); Serial.print(now.year(), DEC); 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.println(); Serial.print("C1 = "); Serial.println(c1); Serial.print("C2 = "); Serial.println(c2); Serial.print("C3 = "); Serial.println(c3); Serial.print("C4 = "); Serial.println(c4); delay(1000); }