#include //#include // Pin connections to the MAX31855x8 board // The power requirement for the board is less than 2mA. Most microcontrollers can source or sink a lot more // than that one each I/O pin. For example, the ATmega328 supports up to 20mA. For convenience, the board // is placed directly on top of a row of I/O pins on the microcontroller. Power is supplied to the board by // holding the GND pin low and the VIN pin high #define GND 3 #define T0 4 #define T1 5 #define T2 6 #define VIN 7 #define MISO 8 #define CS 9 #define SCK 10 // Create the temperature object, defining the pins used for communication MAX31855 temp = MAX31855(MISO, CS, SCK); void setup() { // Display temperatures using the serial port Serial.begin(9600); // Initialize pins pinMode(GND, OUTPUT); pinMode(T0, OUTPUT); pinMode(T1, OUTPUT); pinMode(T2, OUTPUT); pinMode(VIN, OUTPUT); // Power up the board digitalWrite(GND, LOW); digitalWrite(VIN, HIGH); delay(200); } void loop () { // Display the junction temperature float temperature = temp.readJunction(CELSIUS); Serial.print("J="); printTemperature(temperature); // Display the temperatures of the 8 thermocouples for (int therm=0; therm<8; therm++) { // Select the thermocouple digitalWrite(T0, therm & 1? HIGH: LOW); digitalWrite(T1, therm & 2? HIGH: LOW); digitalWrite(T2, therm & 4? HIGH: LOW); // The MAX31855 takes 100ms to sample the thermocouple. // Wait a bit longer to be safe. We'll wait 0.125 seconds delay(1000); temperature = temp.readThermocouple(CELSIUS); if (temperature == FAULT_OPEN) continue; Serial.print(" T"); Serial.print(therm); Serial.print("="); printTemperature(temperature); } Serial.println(); } // Print the temperature, or the type of fault void printTemperature(double temperature) { switch ((int) temperature) { case FAULT_OPEN: Serial.print("FAULT_OPEN"); break; case FAULT_SHORT_GND: Serial.print("FAULT_SHORT_GND"); break; case FAULT_SHORT_VCC: Serial.print("FAULT_SHORT_VCC"); break; case NO_MAX31855: Serial.print("NO_MAX31855"); break; default: Serial.print(temperature); break; } Serial.print(" "); }