Become a subscriber (Free)

Join 29,000 other subscribers to receive subscriber sale discounts and other free resources.
:
:
Don't worry -- your e-mail address is totally secure. I promise to use it only to send you MicroZine.

How to Measure Extreme Temperatures Using the MAX6675 and an Arduino (and a thermocouple)

With the MAX6675 chip and a Type K thermocouple you can easily measure temperature from from 0°C to 1024°C using any microcontroller since the chip outputs data via an SPI interface - here we are going to use it with the Arduino UNO.

The great advantage of the thermocouple is its ease of use when measuring high temperatures and the only other way of doing it is to use a non-contact thermal temperature gun measuring infrared light received, but that is a very expensive option.

This chip is designed specifically for use with the Type K thermocouple and no other, which is not a big problem as the Type-K is the most popular one anyway. The chip does all the hard work for you, and all you do is connect up the thermocouple and read the output from the SPI interface!

TIP: Connect the thermocouple directly to the board connectors or use proper thermocouple extension wire to extend the wiring distance this will ensure a more accurate reading i.e. don't use lots of different connection wires and definitely not different wire lengths or types (for the two thermocouple wires).

A thermocouple is formed from two different metals welded together at the temperature sensing end - The other end should be immersed in an ice bath so that it is kept at 0°C. If this is done then the temperature difference across the thermocouple wire from end-to-end causes a voltage to be generated (the Seebeck effect - discovered around 1821 by Thomas Seebeck) that is proportional to the temperature difference. The diagram below shows a non-ice bath connection see below for why.

Type K Material for thermocouple

Note: A Type K thermocouple is actually composed of Chromel [90% nickel and 10% chromium] and Alumel (Nickel Aluminium) [95% nickel, 2% manganese, 2% aluminium and 1% silicon]] [ source: thermometricscorp.com] and one side is magnetic while the other is not.

The generated voltage is extremely small (~41uV / °C), and is different for different types of thermocouple, so an amplifier is required to turn the reading into a usable form. You don't really want to mess around with an ice bath (unless you want better precision) so a technique called Cold-Junction-Compensation (CJC) is used.

Basically you measure the temperature of the (colder) end of the thermocouple, and figure out the voltage that the thermocouple would have at this temperature, and add this voltage to the thermocouple voltage (you work backwards to find the equivalent voltage when one end is at a temperature of 0°C) i.e. compensate for the ambient temperature at the non-sensing end so that the full temperature reading is made available.

To use a thermocouple you need:

  • An amplifier (high gain).
  • Cold Junction Compensator (or an ice bath).
  • An ADC.

This is where the MAX6675 comes in as it has it all built-in; an in-built amplifier and CJC and ADC. In fact the chip makes using a Type-K thermocouple trivial, as the above are included in the chip and you don't even have to retrieve the analogue value as an ADC is also used, serial digital output in 12bits.

The output format of the MAX6675 is SPI - a digital clocked, read only, interface that provides the 12 output data bits.

Advantages of thermocouples

  • Interchangeable with well defined and repeatable output.
  • Self Exciting (no external power supply required, and hence no self heating problem).
  • Wide temperature measurement range -200°C to 1350°C. (Note: the MAX6675 operates from 0°C to 1024°C).
  • NIST Reference tables exist to allow error correction.
  • Possibility if error correction compensation using polynomial functions.
  • Very fast response time.
  • Convenient and small measurement probe - therefore low thermal mass.

Disadvantages of thermocouples

  • Can not measure lower temperature ranges at high accuracy e.g. 0.1°C (without clever circuits).
  • Not too accurate: Typically 2.2°C for Type K (the thermocouple response alone).
  • Requires no thermal gradient across the system i.e. draughts will cause errors
  • Requires correct thermocouple extension wire to reach distant measuring points.
  • Errors can easily be introduced by incorrect thermal mounting of chip.

Hardware

Since the MAX6675 is packaged as a square outline (SO8) device a surface mount part, you will need a breakout board to access its pins. The breakout boards usually have screw terminals for attaching the thermocouple and header pins for connecting to the Arduino via dupont connectors.

The hardware for this system is really simple; All you need is:

  • Arduino Uno
  • Type K thermocouple
  • MAX6675 breakout board (with chip on board).
  • Dupont connection wires.
  • A usb cable

Optional:

  • DS18B20 - 1 wire thermometer.
  • 10uF capacitor
  • solderless breadboard.

The project is powered from the USB port.

The optional parts above allow you to see how well the thermocouple operates at ambient temperature. I just like to see a comparison of what is going on.

Schematic

arduino thermocouple based temperature measurement

Arduino Library for MAX6675 and DS18B20

Library for MAX6675

  • Library: MAX6675

Goto Arduino Menu: Sketch-->Include Library-->Library Manager.

Then enter MAX6675 in the search box which will show the result:

MAX6675 by Adafruit Version 1.0.0 - Click Install.

You can see that the library is installed by going to Menu: Sketch-->Include Library, scroll down in the drop down box that appears and you will see an entry labeled : MAX6675 Library.

Libraries for DS18B20 (temperature check)

There are two libraries:

  • LIbrary: OneWire (wire.h).
  • Library: MAX31850 Dallas Temp (DallasTemperature.h).

Install/check installation as described for the MAX6675 library.

Arduino code

The following code outputs the thermocouple temperature followed by the DS18B20 temperature. If you don't have the latter, then comment out the DS18B20 code.

Note: Clicking any text in the box below will copy the whole lot to the clipboard.

Untitled
// Prototypes 
void ds18B_setup(void);
void do_max6675_loop(void);
void do_ds18B_loop(void);
 
// Defines
//#define ThermoOnly 1  // For use with IDE Tools --> Serial Plotter

#include <Wire.h>

// Sample Arduino MAX6675 Arduino Sketch

#include "max6675.h"

int ktcSO = 8;
int ktcCS = 9;
int ktcCLK = 10;

MAX6675 ktc(ktcCLK, ktcCS, ktcSO);

void do_max6675_loop(void) {
  // basic readout test

#ifndef ThermoOnly  
   Serial.print("Temp = ");    
   Serial.print(ktc.readCelsius());
   Serial.print("\t Deg F = ");
   Serial.print(ktc.readFahrenheit());
   Serial.print(" Deg C");
#else 
   Serial.println(ktc.readCelsius());    
#endif 
}


#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 4

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature DallasSensors(&oneWire);

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  
#ifndef ThermoOnly    
  Serial.println("Dallas Temperature IC Control Library Demo");
  Serial.println("...and MAX6675 Thermocouple.");

  // Start up the library
  DallasSensors.begin();
#endif

  // give the MAX a little time to settle
  delay(500);
}

void do_ds18B_loop(void)
{ 
  // call DallasSensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  Serial.print("Requesting 1-wire devices...");
  DallasSensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");
  
  Serial.print("Temperature for the device 1 (index 0) is: ");
  Serial.print(DallasSensors.getTempCByIndex(0));
  Serial.println(" Deg C");
}
 
void loop(void) {

#ifndef ThermoOnly   
   Serial.println("\n-START-");
   
   Serial.println("Thermocouple Temp.");
   do_max6675_loop();
   
   Serial.println("\nRoom Temp.");
   do_ds18B_loop();
     
   Serial.print("-END-");
   Serial.print("\n");
#else
  do_max6675_loop(); // Only o/p thermocouple data.
#endif  

   delay(500);
}



Serial Plot

Plotting the output of the thermocouple over time is very easy using the Arduino IDE as there is a built in tool that creates a strip chart that shows the last ~15 minutes of data.To use it you need to output the temperature as a number with no added text around it. The definition "ThermoOnly" does this for you.

By allowing the definition "ThermoOnly" to activate (un-commenting the following line of code):

#define ThermoOnly 1

...then recompile. The sketch will output the temperature value from the thermocouple (and no other text).

Activate the plotter from Menu-->Tools-->Serial Plotter to view the output.

Conclusions on using the MAX6675

The chip makes it easy to obtain temperature readings over a huge temperature range 0°C to 1024°C and employs the most popular thermocouple (Type K). You can also detect small temperature changes as small as 0.25°C (the 12 bit resolution ADC gives this ability [ 1024.0/pow(2,12) = 0.25°C].

The chip also makes interfacing trivially simple because it has built in ADC,CJC and AMP and digital serial output (SPI).

MAX6675 Measurement Accuracy

The basic chip error contribution::

Temperature Range Error (PSU 3V3) Error (PSU 5V) % err (3V3) Additional Cold
comp error ±3.00°C
0 ~ 45°C ±1.00°C ±1.25°C 1°C err 4°C err
0°C ~ +700°C ±2.00°C ±2.25°C @700 ~ 0.29% err @700 ~ 0.7% err
+700°C ~ 1024°C ±4.25°C ±4.75°C @700 ~ 0.7% err,
@1000 ~ 0.4% err
@700 ~ 1.0% err,
@1000 ~ 0.7% err

The only disadvantage of the chip is its accuracy relying on a transistor based temperature measurement that is accurate to only ±3.00°C over the temperature range of the chip (-20°C ~ 85°C). This error will be one of the principal contributors to the total error budget. However thermocouples are not that accurate anyway (specified to 2.2°C) and then there is the error in ADC reading anything from 1°C to 4.75°C (depending on temperature range and chip supply voltage). So you could have an error of 3+4.75+2.2 ~ 11°C. Remember that this is not necessarily too bad as it will give a percentage error of that is still tiny in comparison to the large temperature that is being measured.

However at room temperature the transistor CJC will probably give minimal error e.g. 0°C error (not tested by me just a guesstumate) and below 700°C the error is 2.25°C + thermocouple error of 2.2°C so you could say the error will be 4.47°C but this depends on its usage.

Note: There are techniques to make far more accurate readings with type K thermocouples (calibration and design) but it is beyond the scope of this discussion - since it requires extreme design techniques i.e. a lot of time and thought to get right.

An elegant use of the thermocouple (Gas Pilot control)

I was looking for a bit more information on thermocouples and found this interesting information. If you have ever been caravaning you will know that the fridge can be powered from three sources; mains, 12V and gas. When you use the gas you have to press the starter button (which lights the gas using a piezo lighter but you also have to hold the button for a short time). Why is that? - I never thought to ask and really it's just like magic and it works! - really odd how we just accept the operation of technology around us without questioning it at all!

It turns out that a thermocouple is used to generate a source of voltage (this is why you have to hold the button in for a long time 15-30s) so that the thermocouple has time to warm up. Once it has done so, this very small voltage (of the order of tens of millivolts) is used to power a very small solenoid acting on the holding current alone (Note: the holding current of a solenoid can be far smaller than the activation current and in this case the action of pushing the button is the activation ) so not much power is needed. As long as the flame continues the holding current is generated - and the solenoid remains open..

Some combined main burner and pilot gas valves (mainly by Honeywell) reduce the power demand to within the range of a single universal thermocouple heated by a pilot (25 mV open circuit falling by half with the coil connected to a 10–12 mV, 0.2–0.25 A source, typically) by sizing the coil to be able to hold the valve open against a light spring, but only after the initial turning-on force is provided by the user pressing and holding a knob to compress the spring during lighting of the pilot. These systems are identifiable by the "press and hold for x minutes" in the pilot lighting instructions. (The holding current requirement of such a valve is much less than a bigger solenoid designed for pulling the valve in from a closed position would require.) Special test sets are made to confirm the valve let-go and holding currents, because an ordinary milliammeter cannot be used as it introduces more resistance than the gas valve coil. Apart from testing the open circuit voltage of the thermocouple, and the near short-circuit DC continuity through the thermocouple gas valve coil, the easiest non-specialist test is substitution of a known good gas valve. [Source wikipedia: https://en.wikipedia.org/wiki/Thermocouple ]

What to do with a thermocouple

Measure the temperature output:

  • of your computer (at the fan output) - mine is about 61°C.
  • of a candle flame.
  • of a cup of tea - mine is about 40°C.
  • of a soldering iron - mine is about 300°C.
  • of your oven.
  • of components in your circuit e,g. power transistors (careful some transistors have a voltage at the outer metal can).

Of course once you can measure something, you can then control it e.g an oven, a furnace, high temperature smelting, HVAC, soldering iron etc.

TIP: Set the "#define ThermoOnly" in the example code to uncommented then rebuild the code, then choose the menu from the Arduino IDE to plot the temperature: Menu-->Tools-->Serial Plotter. This will plot out the values of temperature on a graph in real-time. (If you don't see that menu install the IDE from arduino.cc as there are two versions available) .

New! Comments

Have your say about what you just read! Leave me a comment in the box below.



Claim Your: Useful

"Arduino Software Guide"

   Right Now...





Privacy Policy | Contact | About Me

Site Map | Terms of Use



Visit our Facebook Page:

   Click Here



Recent Articles

  1. Using the MAX6675 or How to easily measure Extreme temperatures

    How to use the MAX6675 and an Arduino to measure temperatures from 0°C to 1024°C with two components: A chip - the MAX6675, and a Sensor: - a type-K thermocouple.

    Read more

  2. How to use the DHT22 (or DHT11) with an Arduino; full code and description. Also including a comparison of the DHT11 vs DHT22.

    The Essential Guide to the DHT22/11 humidity sensor including a library code guide for the Arduino. Learn how to determine Humidity, Dew point and Heat Index.

    Read more

  3. How to Use the MAX7219 to drive an 8x8 LED display Matrix on the Arduino.

    The Essential Guide to the MAX7219; What it is and how you can easily use one in any of your projects.

    Read more

Sign up for MicroZine
''The'' Microcontroller Newsletter

Enter your first Name and primary email address in the form below:


And receive absolutely FREE a full project for:

"Measuring Analogue Voltages
Without An ADC"

(Using only one pin).

Instant Download:
You Can
Get It Right Now

Warning: This project could be  Removed 
at any time.  

It will  NOT be 
available indefinitely SO
To avoid 
disappointment  get it:

Now



:
:
Don't worry -- your e-mail address is totally secure. I promise to use it only to send you MicroZine
Remember this is a project with full description and fully debugged C Source code - and it's not available from the main website.

You can only get it through this newsletter.

To get exclusive access Enter your first name Name and primary email address Now in the form above.:



But wait !

There's more...

You'll receive more
free and exclusive reports as well as site information and site product updates


Scroll up to the form above and sign up NOW. Don't forget it's FREE and if you don't like it, you can unsubscribe at any time.

Click Here Now to use the form above to get your Valuable information absolutely free.



Readers Comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's

SUPERB and FANTASTIC."

- Ranish Pottath

"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan

bursach<at>gmail.com<

"Awesome site,
very, very easy and nice
to navigate!"


- Matt
matt_tr<at>
wolf359.cjb.net


Learn Microcontrollers

"Interested in
Microcontrollers?"

Sign up for The
Free 7 day guide:

FREE GUIDE : CLICK HERE


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."


- Dave

de_scott<at>bellsouth.net

"Your site is a great
and perfect work.
congratulations."


- Suresh

integratredinfosys<at>
yahoo.com

"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.
Regards."


- Anon