Lesson 47: Using K-Type MAX6675 as thermostat with relay | Arduino Step By Step Course

Lesson 47: Using K-Type MAX6675 as thermostat with relay | Arduino Step By Step Course

This project guides you through building a temperature control system using an Arduino, a MAX6675 K-type thermocouple, and a relay. This system can maintain a desired temperature range, making it suitable for various applications. You can use this to build:

  • A temperature-controlled incubator for delicate experiments or seedlings.
  • An automated brewing system for maintaining consistent wort temperatures.
  • A climate-controlled enclosure for reptiles or other temperature-sensitive animals.
  • A simple heating or cooling system for a small space.

The system uses the MAX6675 to read temperatures from a K-type thermocouple, providing accurate temperature readings over a wide range (depending on the thermocouple type, up to 1000°C or more). The Arduino processes these readings and controls a relay to switch a heating or cooling element on or off, maintaining the temperature within a user-defined range. (in video at 00:32)

Hardware/Components

To build this project, you will need the following components:

  • Arduino board (Uno, Nano, etc.)
  • MAX6675 thermocouple amplifier
  • K-type thermocouple
  • Relay module
  • AC bulb (or other load, such as a fan or heater)
  • Jumper wires
  • Breadboard (optional, but recommended)

Wiring Guide

The wiring is explained in detail in the video. (in video at 03:28) Refer to the video for a visual guide. The key connections include connecting the MAX6675 to the Arduino (pins 2-6), the relay module to the Arduino (pin 8 and power), and the relay module to the AC load. A critical aspect is correctly identifying the live and neutral wires of your AC load before connecting them to the relay. Incorrect wiring can lead to dangerous situations.

Code Explanation

The Arduino code (shown in snippets below) utilizes the MAX6675 library to read temperature values from the thermocouple. The user-configurable parts of the code are:

  • relayPin: The Arduino pin connected to the relay module (default: 8). (in video at 07:35)
  • relayON and relayOFF: These constants define the logic levels to turn the relay on and off, respectively. These are usually LOW and HIGH, but might need to be adjusted depending on your relay module. (in video at 07:35)
  • TEMPERATURE_UNIT: Sets the unit for temperature readings (1 for Celsius, 2 for Fahrenheit, 3 for Kelvin). (in video at 08:21)
  • START_TEMPERATURE and STOP_TEMPERATURE: These variables define the temperature range for the control system. The system will turn on the relay when the temperature falls below START_TEMPERATURE and turn it off when the temperature reaches STOP_TEMPERATURE (or vice-versa, depending on whether you're controlling a heater or cooler). (in video at 08:31)
  • CONTROL_TYPE: A variable that determines whether the system acts as a heater (1) or cooler (2). (in video at 08:36)

The code includes functions like readTemperature(), printTemperature(), loadControl(), and relayControl() to handle temperature reading, display, and relay operation. These functions are clearly defined and explained in the video. (in video at 09:37, 10:00, 10:43, 11:30)


const int relayPin =8;
const int relayON = LOW;// do not change
const int relayOFF = HIGH; //do not change 
int relayState = relayOFF;//initial state of relay

const int TEMPERATURE_UNIT =1;//1=Celsius, 2=Fahrenheit, 3=Kelvin
const float START_TEMPERATURE = 80.0;//unit above
const float STOP_TEMPERATURE = 100.0;//unit above
const int CONTROL_TYPE = 1;// 1= heater, 2=cooler

Live Project/Demonstration

The video demonstrates the functioning of the temperature control system for both heating and cooling scenarios. (in video at 13:15 and 15:28) The demonstration clearly shows how the system maintains the temperature within the set range by turning the relay on and off as needed.

Chapters

  • [00:00] Introduction
  • [00:55] Heater/Cooler Control Explanation
  • [03:28] Wiring Diagram
  • [06:26] Code Explanation
  • [13:15] Heater Control Demonstration
  • [15:28] Cooler Control Demonstration
  • [17:29] Conclusion
25-Arduino code for a MAX6675 K-type thermocouple with relay (no display)
Sprache: C++
757-Arduino code to measure a MAX6675 K-type thermocouple
Sprache: C++
Kopiert!

Dinge, die Sie vielleicht brauchen

Ressourcen & Referenzen

Dateien📁

Keine Dateien verfügbar.