Этот учебник является частью: Управление реле с помощью Arduino
Это подборка видеороликов, посвященных эстафете. Ссылки на другие видео находятся ниже этой статьи.
Using a MAX6675 K-Type Thermocouple with Relay and Display
This project demonstrates how to interface a MAX6675 K-type thermocouple with an Arduino, incorporating a relay for control and a display for temperature readings. This setup is invaluable for various applications where precise temperature monitoring and automated responses are needed. Here are some project ideas:

- Overheat protection for sensitive electronics
- Temperature-controlled incubator for biological experiments
- Automated brewing system for coffee or beer
- Industrial process monitoring and control
- Environmental monitoring in a greenhouse or other controlled environment
Hardware/Components
To build this project, you will need the following components:
- Arduino Uno (or compatible board)
- MAX6675 K-type thermocouple module (in video at 00:58)
- Relay module
- TM1637 4-digit LED display module
- Jumper wires
- Connecting wires
Wiring Guide
The wiring is explained in the video (in video at 05:36). The specific connections depend on whether you are using a surface mount chip or a PCB module. Refer to the video for a detailed wiring diagram.

Code Explanation
The Arduino code uses the MAX6675 library to read temperature values from the thermocouple. The key configurable parts of the code are:
- Thermocouple pin definitions:
thermoDO,thermoCS, andthermoCLK(in video at [03:53]). These pins need to be adjusted according to your wiring scheme. - Relay control pin: Pin 10 is used to control the relay (in video at [05:36]). Change this if needed.
- Display configuration (if used): The code includes sections for configuring the TM1637 display. Adjust the CLK and DIO pins if necessary (in video at [03:53]).
The code includes functions to read temperature in Celsius and Fahrenheit. A crucial part of the code is the conditional statement that checks if the temperature exceeds a threshold (80.0°C in this example). If it does, the relay is activated (pin 10 goes LOW).
// 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
}
Live Project/Demonstration
The video demonstrates the project in action (in video at 06:59). The sensor accurately reads the ambient temperature and increases when heated. The relay functionality is also showcased.
Chapters
- [00:00] Introduction
- [00:39] Sensor Overview
- [01:40] Pin Connections
- [02:22] Library Installation
- [03:53] Code Explanation (Setup)
- [04:06] Code Explanation (Loop)
- [05:36] Wiring
- [06:59] Live Demonstration
Этот учебник является частью: Управление реле с помощью Arduino
- Arduino Code and Video for a Dual-Channel 5V Relay
- Controlling a 5V Relay Using Arduino to cotrol AC or DC load like bulb or motor
- TTP224 4-Channel Touch Sensor to Turn AC/DC Loads with Relay
- Использование релейного модуля на 5В (низкий триггер) с Arduino
- Using a Reed Switch to Control a Relay and AC/DC Loads with an Arduino
- Using a TTP223B touch module and relay to control AC/DC loads with an Arduino
- Using an Arduino push button to switch a relay and AC bulb
/*
* 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);
}
/*
* Это код Arduino для термопары типа K MAX6675 с реле и дисплеем. Выходной пин 10 подключен к реле. Когда температура достигает желаемого значения, пин 10 включает реле.
*
* Этот код был объяснен в нашем видео на https://youtu.be/cD5oOu4N_AE
*
* Написано Ахмадом Неджраби для Robojax Video Дата: 9 декабря 2017 года, в Эйджаксе, Онтарио, Канада Разрешение дано на распространение этого кода при условии, что эта заметка остаётся с кодом. Отказ от ответственности: этот код предоставляется "КАК ЕСТЬ" и только в образовательных целях.
*/
#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);
// Используйте пины Arduino
pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
pinMode(10, OUTPUT); // установить пин 10 как выходной
Serial.println("Robojax: MAX6675 test");
// ждите, пока чип MAX стабилизируется
delay(500);
}
void loop() {
// базовый тест считывания, просто выведите текущую температуру
Serial.print("C = ");
Serial.println(thermocouple.readCelsius());
Serial.print("F = ");
Serial.println(thermocouple.readFahrenheit());
// Если температура поднимается выше 80,0°C, включите реле.
if(thermocouple.readCelsius() > 80.00){
digitalWrite(10, LOW); // установить вывод 10 на LOW
}else{
digitalWrite(10, HIGH); // установить вывод 10 в HIGH
}
delay(1000);
}
/*
* Это код Arduino для термопары типа K MAX6675 с реле и дисплеем. Выходной пин 10 подключен к реле. Когда температура достигает заданного значения, пин 10 включает реле. Температура также отображается на дисплее. Вы должны включить библиотеку TM1637, чтобы дисплей работал. Вы можете скачать TM1637 с http://robojax.com/learn/library. Этот код был объяснен в нашем видео по адресу https://youtu.be/cD5oOu4N_AE.
*
* Написано Ахмадом Нежараби для Robojax Video. Дата: 9 декабря 2017 года, в Айдже, Онтарио, Канада. Разрешение на распространение этого кода дано при условии, что эта заметка будет сохранена с кодом. Отказ от ответственности: этот код предоставляется "КАК ЕСТЬ" и только для образовательных целей.
*/
#include "max6675.h"
#include <Arduino.h>
#include <TM1637Display.h>
int thermoDO = 4;
int thermoCS = 5;
int thermoCLK = 6;
// Код для отображения
#define CLK 2
#define DIO 3
#define TEST_DELAY 2000
TM1637Display display(CLK, DIO);
// Код для отображения конца
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
int vccPin = 3;
int gndPin = 2;
void setup() {
Serial.begin(9600);
// Используйте пины Arduino
pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
pinMode(10, OUTPUT); // установить пин 10 как выходной
Serial.println("Robojax: MAX6675 test");
// ждать, пока чип MAX стабилизируется
delay(500);
}
void loop() {
// Базовый тест считывания, просто выведите текущую температуру.
// Код для отображения
display.setBrightness(0x0f);
// Все сегменты включены
uint8_t data[] = { 0x0, 0x0, 0x0, 0x0 };
display.setSegments(data);
delay(1);
int temp = (int) thermocouple.readCelsius();
display.showNumberDec(temp, true, 3, 0);
// Код для отображения конца
Serial.print("C = ");
Serial.println(thermocouple.readCelsius());
Serial.print("F = ");
Serial.println(thermocouple.readFahrenheit());
// Если температура поднимается выше 80,0°C, включите реле.
if(thermocouple.readCelsius() > 80.00){
digitalWrite(10, LOW); // установить пин 10 низким
}else{
digitalWrite(10, HIGH); // установить пин 10 ВЫСОКИЙ
}
delay(1000);
}
/*
* Это код Arduino для термопары типа K MAX6675 с реле и дисплеем. Выходной контакт 10 подключен к реле. Когда температура достигает нужного значения, контакт 10 включает реле.
*
* Этот код объяснен в нашем видео на https://youtu.be/cD5oOu4N_AE
*
* Автор: Ахмад Шамшири для Robojax Video
* Дата: 2 июня 2018 года, в Аяксе, Онтарио, Канада
* Разрешение дано на распространение этого кода при условии, что эта заметка будет сохранена вместе с кодом.
* Отказ от ответственности: Этот код "КАК ЕСТЬ" и предназначен только для образовательных целей.
*/
#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); // первый термопара
MAX6675 thermocouple2(thermoCLK2, thermoCS2, thermoDO2); // 2-й термопара
int vccPin1 = 3;
int gndPin1 = 2;
int relayPin1 =10;
int vccPin2 = 11;
int gndPin2 = 12;
int relayPin2 =13;
void setup() {
Serial.begin(9600);
// используйте пины Arduino
pinMode(vccPin1, OUTPUT); digitalWrite(vccPin, HIGH);
pinMode(gndPin1, OUTPUT); digitalWrite(gndPin, LOW);
pinMode(relayPin1, OUTPUT); // установите вывод 10 в качестве выхода для термопары 1
pinMode(vccPin2, OUTPUT); digitalWrite(vccPin, HIGH);
pinMode(gndPin2, OUTPUT); digitalWrite(gndPin, LOW);
pinMode(relayPin2, OUTPUT); // установить пин 13 как выход для термопары 2
Serial.println("Robojax: MAX6675 test");
// ждать, пока чип MAX стабилизируется
delay(500);
}
void loop() {
// базовый тест считывания, просто выведите текущую температуру
// для термопары 1
Serial.print("C = ");
Serial.println(thermocouple.readCelsius());
Serial.print("F = ");
Serial.println(thermocouple.readFahrenheit());
// если температура поднимается выше 80,0 °C, включите реле
if(thermocouple1.readCelsius() > 80.00){
digitalWrite(relayPin1, LOW); // установить пин relayPin1 в НИЗКИЙ
}else{
digitalWrite(relayPin1, HIGH); // установить пин relayPin1 ВЫСОКИЙ
}
// термопара1 конец
// для термопары 2
Serial.print("C2 = ");
Serial.println(thermocouple2.readCelsius());
Serial.print("F2 = ");
Serial.println(thermocouple2.readFahrenheit());
// если температура поднимается выше 80,0 °C, включите реле
if(thermocouple2.readCelsius() > 80.00){
digitalWrite(relayPin2, LOW); // установить пин relayPin2 НИЖНИЙ
}else{
digitalWrite(relayPin2, HIGH); // установить пин relayPin2 ВЫСОКИЙ
}
// термопара2 конец
delay(1000);
}
Ресурсы и ссылки
Файлы📁
Нет доступных файлов.