코드 검색

MAX6675 K형 열전대를 릴레이 및 디스플레이와 함께 사용하기

MAX6675 K형 열전대를 릴레이 및 디스플레이와 함께 사용하기

이 프로젝트는 MAX6675 K형 열전대를 Arduino와 인터페이스하는 방법을 보여주며, 제어를 위한 릴레이와 온도 판독을 위한 디스플레이를 통합합니다. 이 설정은 정밀한 온도 모니터링과 자동 응답이 필요한 다양한 응용 분야에서 매우 유용합니다. 몇 가지 프로젝트 아이디어는 다음과 같습니다:

MAX6675 Thermocoupler module
  • 민감한 전자 장치의 과열 보호
  • 생물학적 실험을 위한 온도 조절 인큐베이터
  • 커피 또는 맥주를 위한 자동 양조 시스템
  • 산업 공정 모니터링 및 제어
  • 온실 또는 기타 통제된 환경에서의 환경 모니터링

하드웨어/부품

이 프로젝트를 구축하려면 다음 구성 요소가 필요합니다:

  • Arduino Uno (또는 호환 보드)
  • MAX6675 K형 열전대 모듈 (비디오 00:58에서)
  • 릴레이 모듈
  • TM1637 4자리 LED 디스플레이 모듈
  • 점퍼 와이어
  • 연결 와이어

배선 가이드

배선은 비디오에서 설명됩니다 (비디오 05:36에서). 특정 연결은 표면 실장 칩을 사용하는지 PCB 모듈을 사용하는지에 따라 다릅니다. 자세한 배선도는 비디오를 참조하십시오.

Arduino wiring for MAX6675 Thermocoupler module
Arduino wiring for MAX6675 Thermocoupler module

코드 설명

Arduino 코드는 MAX6675 라이브러리를 사용하여 열전대에서 온도 값을 읽습니다. 코드의 주요 구성 가능한 부분은 다음과 같습니다:

  • 열전대 핀 정의: thermoDO, thermoCSthermoCLK (비디오 [03:53]에서). 이 핀은 배선 방식에 따라 조정해야 합니다.
  • 릴레이 제어 핀: 핀 10은 릴레이를 제어하는 데 사용됩니다 (비디오 [05:36]에서). 필요한 경우 변경하십시오.
  • 디스플레이 구성 (사용하는 경우): 코드에는 TM1637 디스플레이 구성 섹션이 포함됩니다. 필요한 경우 CLK 및 DIO 핀을 조정하십시오 (비디오 [03:53]에서).

코드에는 섭씨와 화씨로 온도를 읽는 함수가 포함됩니다. 코드의 중요한 부분은 온도가 임계값(이 예에서는 80.0°C)을 초과하는지 확인하는 조건문입니다. 초과하면 릴레이가 활성화됩니다 (핀 10이 LOW로 설정됨).


// 온도가 80.0C 이상이면 릴레이를 켭니다
if(thermocouple.readCelsius() > 80.00){
  digitalWrite(10, LOW);// 핀 10을 LOW로 설정
} else {
  digitalWrite(10, HIGH);// 핀 10을 HIGH로 설정
}

실시간 프로젝트/데모

비디오는 프로젝트가 작동하는 모습을 보여줍니다 (비디오 06:59에서). 센서는 주변 온도를 정확히 읽고 가열 시 증가합니다. 릴레이 기능도 시연됩니다.

챕터

  • [00:00] 소개
  • [00:39] 센서 개요
  • [01:40] 핀 연결
  • [02:22] 라이브러리 설치
  • [03:53] 코드 설명 (설정)
  • [04:06] 코드 설명 (루프)
  • [05:36] 배선
  • [06:59] 실시간 데모

이미지

MAX6675 Thermocoupler module
MAX6675 Thermocoupler module
K-Type Thermocoupler module with wire
K-Type Thermocoupler module with wire
K-Type thermocoupler connector
K-Type thermocoupler connector
Arduino wiring for MAX6675 Thermocoupler module
Arduino wiring for MAX6675 Thermocoupler module
MAX6675 Thermocoupler module
MAX6675 Thermocoupler module
24-Arduino code for a MAX6675 K-type thermocouple (without relay and display)
언어: C++
/*
 * This is the Arduino code for MAX6675 Thermocouple K-Type with Relay and Display.
 * This code has been explained in our video at https://youtu.be/cD5oOu4N_AE.

 * 
 * Written by Ahmad Shamshiri for Robojax Video
 * Date: December 9, 2017, 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 purposes only.
 * 
 */

 // This example is public domain. Enjoy!
// www.ladyada.net/learn/sensors/thermocouple

#include "max6675.h"


int thermoDO = 4;
int thermoCS = 5;
int thermoCLK = 6;


MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
int vccPin = 3;
int gndPin = 2;
  
void setup() {
  Serial.begin(9600);
  // Use Arduino pins 
  pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
  pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
  
  Serial.println("Robojax: MAX6675 test");
  // Wait for MAX chip to stabilize
  delay(500);
}

void loop() {
  // Basic readout test, just print the current temperature


   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(thermocouple.readCelsius() > 80.00){
    digitalWrite(10, LOW);// Set pin 10 LOW
   }else{
    digitalWrite(10, HIGH);// Set pin 10 HIGH
   }
    
 
   delay(1000);
}
25-Arduino code for a MAX6675 K-type thermocouple with relay (no display)
언어: C++
/*
 * This is the Arduino code for MAX6675 Thermocouple K-Type with Relay and Display
 * The output pin 10 is connected to the relay.
 * When the temperature reaches the desired value, pin 10 turns the 
 * relay ON.

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

 * 
 * Written by Ahmad Nejrabi for Robojax Video
 * Date: December 9, 2017, 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 purposes only.
 * 
 */

 // This example is public domain. Enjoy!
// www.ladyada.net/learn/sensors/thermocouple

#include "max6675.h"


int thermoDO = 4;
int thermoCS = 5;
int thermoCLK = 6;


MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
int vccPin = 3;
int gndPin = 2;
  
void setup() {
  Serial.begin(9600);
  // Use Arduino pins 
  pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
  pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
    pinMode(10, OUTPUT);// set pin 10 as output
	
  Serial.println("Robojax: MAX6675 test");
  // wait for MAX chip to stabilize
  delay(500);
}

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


   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(thermocouple.readCelsius() > 80.00){
    digitalWrite(10, LOW);// set pin 10 LOW
   }else{
    digitalWrite(10, HIGH);// set pin 10 HIGH
   }
    
 
   delay(1000);
}
26-Arduino code for a MAX6675 K-type thermocouple with relay and display
언어: C++
/*
 * This is the Arduino code for MAX6675 Thermocouple K-Type with Relay and Display
 * The output pin 10 is connected to the relay.
 * When the temperature reaches the desired value, pin 10 turns the 
 * relay ON.
 * The temperature is also displayed on the display.
 * You must include the TM1637 library to make the display work. 
 * You can download the TM1637 from http://robojax.com/learn/library
 * This code has been explained in our video at https://youtu.be/cD5oOu4N_AE

 * 
 * Written by Ahmad Nejrabi for Robojax Video
 * Date: December 9, 2017, 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 purposes only.
 * 
 */

 // This example is public domain. Enjoy!
// www.ladyada.net/learn/sensors/thermocouple

#include "max6675.h"
#include <Arduino.h>
#include <TM1637Display.h>

int thermoDO = 4;
int thermoCS = 5;
int thermoCLK = 6;

// Code for display 
#define CLK 2
#define DIO 3
#define TEST_DELAY   2000
TM1637Display display(CLK, DIO);
// Code for display end

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
int vccPin = 3;
int gndPin = 2;
  
void setup() {
  Serial.begin(9600);
  // Use Arduino pins 
  pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
  pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
  pinMode(10, OUTPUT);// set pin 10 as output
	
  Serial.println("Robojax: MAX6675 test");
  // wait for MAX chip to stabilize
  delay(500);
}

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

	// Code for display
  display.setBrightness(0x0f);
    // All segments on
  uint8_t data[] = { 0x0, 0x0, 0x0, 0x0 };
  display.setSegments(data);
  delay(1);
  int temp = (int) thermocouple.readCelsius();
  display.showNumberDec(temp, true, 3, 0);
  // Code for display end
   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(thermocouple.readCelsius() > 80.00){
    digitalWrite(10, LOW);// set pin 10 LOW
   }else{
    digitalWrite(10, HIGH);// set pin 10 HIGH
   }
    
 
   delay(1000);
}
27-Arduino code for two MAX6675 K-type thermocouples with relay (no display)
언어: C++
/*
 * This is the Arduino code for MAX6675 Thermocouple K-Type with Relay and Display
 * The output pin 10 is connected to the relay.
 * When the temperature reaches the desired value, pin 10 turns 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 purposes 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);
}

파일📁

다른 파일들