Arduino code for 2pcs of MAX6675 Thermocouple K-Type with Relay (no display) Example 4/4

Project Video
Project Details

This video shows you how to turn AC load like bulb ON and off using TTP223B touch module with a relay.
This demonstration and code will shows how to use it with Arduino and without Arduino.
You will also learn how to connect if your relay is different.
The last section of the video shows you how to control the time, the AC bulb or load is ON.

This code is to connect 2 MAX6675 Thermocouple and measure separately.

Watch the TM1637 Display video and get the code
See >MAX6675 Thermocouple K-Type code for Arduino (without relay and display) Example 1/4
See Arduino code for MAX6675 Thermocouple K-Type with Relay (no display) Example 2/4
See Arduino code for MAX6675 Thermocouple K-Type with Relay and Display Example 3/4
See Arduino code for 2pcs of MAX6675 Thermocouple K-Type with Relay (no display) Example 4/4

Project Code


/*
 * This is the Arduino code for MAX6675 Thermocouple K-Type with Relay and Display
 * the output pen 10 is connected to relay 
 * by when the temprature reaches desired value, the in 10 turns the 
 * the relay ON.

 * this code has been explained in our video at https://youtu.be/cD5oOu4N_AE

 * 
 * Written by Ahmad Shamshiri for Robojax Video
 * Date: June 02, 2018, in Ajax, Ontario, Canada
 * Permission granted to share this code given that this
 * note is kept with the code.
 * Disclaimer: this code is "AS IS" and for educational purpose only.
 * 
 */

 // this example is public domain. enjoy!
// www.ladyada.net/learn/sensors/thermocouple

#include "max6675.h"


int thermoDO1 = 4;
int thermoCS1 = 5;
int thermoCLK1 = 6;

int thermoDO2 = 7;
int thermoCS2 = 8;
int thermoCLK3 = 9;


MAX6675 thermocouple1(thermoCLK1, thermoCS1, thermoDO1);// first thermocouple
MAX6675 thermocouple2(thermoCLK2, thermoCS2, thermoDO2);// 2nd thermocouple
int vccPin1 = 3;
int gndPin1 = 2;
int relayPin1 =10;

int vccPin2 = 11;
int gndPin2 = 12;
int relayPin2 =13;
  
void setup() {
  Serial.begin(9600);
  // use Arduino pins 
  pinMode(vccPin1, OUTPUT); digitalWrite(vccPin, HIGH);
  pinMode(gndPin1, OUTPUT); digitalWrite(gndPin, LOW);
    pinMode(relayPin1, OUTPUT);// set pin 10 as output for thermocouple1
	
  pinMode(vccPin2, OUTPUT); digitalWrite(vccPin, HIGH);
  pinMode(gndPin2, OUTPUT); digitalWrite(gndPin, LOW);
    pinMode(relayPin2, OUTPUT);// // set pin 13 as output for thermocouple2
	
  Serial.println("Robojax: MAX6675 test");
  // wait for MAX chip to stabilize
  delay(500);
}

void loop() {
  // basic readout test, just print the current temp

// for thermocouple 1
   Serial.print("C = "); 
   Serial.println(thermocouple.readCelsius());
   Serial.print("F = ");
   Serial.println(thermocouple.readFahrenheit());

   // if temperature goes above 80.0C, turn the relay ON
   if(thermocouple1.readCelsius() > 80.00){
    digitalWrite(relayPin1, LOW);// set pin relayPin1 LOW
   }else{
    digitalWrite(relayPin1, HIGH);// set pin relayPin1 HIGH
   }
// thermocouple1 end

// for thermocouple 2
   Serial.print("C2 = "); 
   Serial.println(thermocouple2.readCelsius());
   Serial.print("F2 = ");
   Serial.println(thermocouple2.readFahrenheit());

   // if temperature goes above 80.0C, turn the relay ON
   if(thermocouple2.readCelsius() > 80.00){
    digitalWrite(relayPin2, LOW);// set pin relayPin2 LOW
   }else{
    digitalWrite(relayPin2, HIGH);// set pin relayPin2 HIGH
   }   
// thermocouple2 end
 
   delay(1000);
}