Using K-Type Thermocoupler MAX6675 using ESP32 with Arduino IDE
Using K-Type Thermocoupler MAX6675 using ESP32 with Arduino IDE
In this tutorial we learn how to use MAX6675 Thermocouple sensor with ESP32 to measure temperature and read it on serial monitor of your computer or do take action.
If you need to use 2 or more MAX6675 thermocouple sensor with ESP32 (no bluetooth) See this page
If you need to use MAX6675 thermocouple sensor with ESP32 with bluetooth See this page
- MAX6675 Adafruit Library (GetHub)
- Preparing your Arduino IDE to work with ESP32
- MAX6675 k type with Arduino (without display) (video and code)
- MAX6675 k type with Arduino with LCD1602 I2C (video and code)
- MAX6675 k type with Arduino (without display)
- download MAX6675 Library (from Robojax.com)
- Robojax Crash Course on Arduino: Learn Arduino in 30 Minutes (code and video)
- Robojax Arduino Course on Udemy
- Get Early Access to my videos via Patreon
Arduino code for MAX6675 with ESP32 Bluetooth
/*
*
*
* This is Arduino code to Measure Temperature
MAX6675 with ESP32 print on the serial monitor
* Watch video instruction for wriring 0nly: https://youtu.be/Zm8Xor_vYF4
* Written/updated by Ahmad Shamshiri for Robojax Video channel www.Robojax.com
* Date: July 08, 2020, in Ajax, Ontario, Canada
updated on Feb 05, 2021
Related videos:
Introduction to MAX6675 K-Type: https://youtu.be/VGqONmUinqA
Using MAX6675 K-Type thermocouple whit LED display: https://youtu.be/cD5oOu4N_AE
Using MAX6675 K-Type thermocouplewith LCD1602-I2C: https://youtu.be/BlhpktgPdKs
Using 2 or more MAX6675 K-Type thermocouple: https://youtu.be/c90NszbNG8c
Using MAX6675 K-Type with ESP32 over Bluetooth: [this video]
* this code has been downloaded from http://robojax.com/learn/arduino/
* Get this code and other Arduino codes from Robojax.com
Learn Arduino step by step in structured course with all material, wiring diagram and library
all in once place. Purchase My course on Udemy.com http://robojax.com/L/?id=62
****************************
Get early access to my videos via Patreon and have your name mentioned at end of very
videos I publish on YouTube here: http://robojax.com/L/?id=63 (watch until end of this video to list of my Patrons)
****************************
or make donation using PayPal http://robojax.com/L/?id=64
* * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.*
* This code has been download from Robojax.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
///////// Start of MAX6675 settings
#include "max6675.h"
//Robojax.com MAX6675 Thermocoupler
int thermoCLK = 12;
int thermoCS = 14;
int thermoDO = 27;
float tempC, tempF, tempK;
char *titleTemp="Temperature: ";
int type=1;// 1=C, 2=F, 3=K,
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
/////////////// end of MAX6675 settings
void setup() {
Serial.begin(115200);
Serial.println("Robojax MAX6675 with ESP32");
Serial.println("to read temperature");
//Robojax.com MAX6675 with ESP32 (without bluetooth)
}
void loop() {
getTemp();// this reas the temperature
Serial.println(thermocouple.readCelsius());
//Robojax.com MAX6675 with ESP32
prinTemp(1);//print temperature in Celsius
prinTemp(2);//print temperature in Fahrenheit
prinTemp(3);//print temperature in Kelvin
// if temperature in Celsius is greator thatn 125 do something
if(tempC > 125)
{
// do something here
}
delay(300);//change this delay to make it faster or slower. 100 makes it slower
//Robojax.com MAX6675 with ESP32
}//loop ends here
/*
* @brief prints temperature
* @return returns none
* Usage: to get Fahrenheit type: prinTemp(1), prinTemp(2), prinTemp(3)
1-Celsius prinTemp(1)
2-Fahrenheit prinTemp(2)
3-Kelvin prinTemp(3)
* to print it on serial monitor
* Written by Ahmad Shamshiri on Feb 05, 2021
* in Ajax, Ontario, Canada
* www.Robojax.com
*/
void prinTemp(int type)
{
//Robojax.com MAX6675 with ESP32
Serial.print(titleTemp);
if(type ==1)
{
Serial.print(tempC);
Serial.println("°C");
}
if(type ==2)
{
Serial.print(tempF);
Serial.println("°F");
}
if(type ==3)
{
Serial.print(tempK);
Serial.println("°K");
}
//Robojax.com MAX6675 with ESP32
}//sendTemp ends here
/*
* @brief returns temperature or relative humidity
* @return returns one of the values above
* Usage: to get Fahrenheit type: getTemp('F')
* to print it on serial monitor Serial.println(getTemp('F'));
* Written by Ahmad Shamshiri on Mar 30, 2020.
* in Ajax, Ontario, Canada
* www.Robojax.com
*/
void getTemp()
{
//Robojax.com with MAX6675 Thermocoupler
tempF = thermocouple.readFahrenheit();// Fahrenheit
tempK= thermocouple.readCelsius() + 273.15;//convert to Kelvin
tempC = thermocouple.readCelsius();// Celsius
//Robojax.com MAX6675 Thermocoupler
}//getTemp