ค้นหาโค้ด

ใช้ MAX6675 เทอร์โมคัปเปิลชนิด K ร่วมกับรีเลย์และจอแสดงผล

ใช้ MAX6675 เทอร์โมคัปเปิลชนิด K ร่วมกับรีเลย์และจอแสดงผล

โปรเจกต์นี้สาธิตวิธีการเชื่อมต่อเทอร์โมคัปเปิลชนิด K MAX6675 กับ Arduino โดยรวมรีเลย์สำหรับการควบคุมและจอแสดงผลสำหรับการอ่านค่าอุณหภูมิ การตั้งค่านี้มีค่าอย่างยิ่งสำหรับการใช้งานต่างๆ ที่ต้องการการตรวจสอบอุณหภูมิที่แม่นยำและการตอบสนองอัตโนมัติ นี่คือแนวคิดโปรเจกต์บางส่วน:

MAX6675 Thermocoupler module
  • การป้องกันความร้อนเกินสำหรับอุปกรณ์อิเล็กทรอนิกส์ที่ละเอียดอ่อน
  • ตู้ฟักที่ควบคุมอุณหภูมิสำหรับการทดลองทางชีววิทยา
  • ระบบชงกาแฟหรือเบียร์อัตโนมัติ
  • การตรวจสอบและควบคุมกระบวนการทางอุตสาหกรรม
  • การตรวจสอบสิ่งแวดล้อมในเรือนกระจกหรือสภาพแวดล้อมที่ควบคุมอื่นๆ

ฮาร์ดแวร์/ส่วนประกอบ

ในการสร้างโปรเจกต์นี้ คุณจะต้องมีส่วนประกอบดังต่อไปนี้:

  • Arduino Uno (หรือบอร์ดที่เข้ากันได้)
  • โมดูลเทอร์โมคัปเปิลชนิด K MAX6675 (ในวิดีโอที่ 00:58)
  • โมดูลรีเลย์
  • โมดูลจอแสดงผล LED 4 หลัก TM1637
  • สายจัมเปอร์
  • สายเชื่อมต่อ

คู่มือการเดินสายไฟ

การเดินสายไฟอธิบายไว้ในวิดีโอ (ในวิดีโอที่ 05:36) การเชื่อมต่อเฉพาะขึ้นอยู่กับว่าคุณใช้ชิปแบบ surface mount หรือโมดูล PCB โปรดดูวิดีโอสำหรับแผนผังการเดินสายไฟโดยละเอียด

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

คำอธิบายโค้ด

โค้ด Arduino ใช้ไลบรารี MAX6675 เพื่ออ่านค่าอุณหภูมิจากเทอร์โมคัปเปิล ส่วนสำคัญของโค้ดที่สามารถกำหนดค่าได้คือ:

  • การกำหนดพินเทอร์โมคัปเปิล: thermoDO, thermoCS และ thermoCLK (ในวิดีโอที่ [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);
}

แหล่งข้อมูลและเอกสารอ้างอิง

ไฟล์📁

ไฟล์อื่น ๆ