MAX6675: How to Measure Extreme Temperatures with Arduino. The Type-K Thermocouple interface makes
Reading Temperatures from 0°C to 1024°C Easy, and the SPI interface lets you take
readings Fast.
MAX6675:
How to measure temperature from 0°C to 1024°C.
Has a built-in ADC,
Has a built-in Cold Junction Compensation.
Has a digital SPI interface for fast data output.
With this 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 you use the
Arduino Uno as the controller.
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) - since these will become thermocouples!
Seebeck Effect
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.
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.
Cold Junction Compensation
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.
MAX6675
This is where the MAX6675 comes in as it has everything built-in
already for
you; a in-built amplifier, Cold -Junction-Compensator (CJC) and an 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 the ADC generates a
digital output which is transmitted as a 12bit serial sequence.
The output format of the MAX6675 is SPI - a digital clocked, read only,
interface that provides the 12 output data bits.
* - The max output from the SO pin is 50mA but you won't design it that
badly will you? If you feed the SO outpout into a normal microcontroller input
(since that is a CMOS input) there will hardly be any current drawn at all so
you will be left with the 1.5mA max supply current for the MAX6675.
** - See also the error analysis for different temperature ranges here (in this page).
Advantage and Disadvantages
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 Needed
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.
MAX6675 Schematic
The schematic below shows connection for the MAX6675 breakout board and also
the DS18B20 temperature sensor. This is used to show an accurate temperature
for lower temperatures so you can get a feel for how the thermocouple is
operating.
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.
Install/check installation as described for the MAX6675 library.
MAX6675 Arduino Example 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.
// Prototypes
voidds18B_setup(void);
voiddo_max6675_loop(void);
voiddo_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"
intktcSO=8;
intktcCS=9;
intktcCLK=10;
MAX6675ktc(ktcCLK,ktcCS,ktcSO);
voiddo_max6675_loop(void){
// basic readout test
#ifndefThermoOnlySerial.print("Temp = ");Serial.print(ktc.readCelsius());
Serial.print("\t Deg F = ");
Serial.print(ktc.readFahrenheit());
Serial.print(" Deg C");
#elseSerial.println(ktc.readCelsius());#endif}
#include<OneWire.h>
#include<DallasTemperature.h>
// Data wire is plugged into port 2 on the Arduino
#defineONE_WIRE_BUS4
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWireoneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperatureDallasSensors(&oneWire);
voidsetup(void)
{
// start serial port
Serial.begin(9600);
#ifndefThermoOnlySerial.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);
}
voiddo_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");
}
voidloop(void){
#ifndefThermoOnlySerial.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.
#endifdelay(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 - uncomment it to allow this mode of operation.
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.
Details for 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.
Conclusions on the MAX6675
The 6675 is a linear device that amplifies the thermoelectric voltage
~41uV/°C by a constant and digitises the result. The output from the the
amplifier is fed into a 12 bit ADC resulting in a resolution of 0.25°C and its
main advantage is that it does this job inside the chip (amplifying an
extremely low signal into a usable voltage that is turned into a digital
output).
There are two minor drawbacks:
The MAX6675 can only operate over the temperature range of 0°C to
1024°C when in fact the Type K thermocouple is capable of operating over
the range -200°C to 1300°C!
The accuracy of the reading is dependent on the charactristics of the
Type K thermocouple (which is not linear over the range 0°C to 1024°C) so
the error details quoted above are a direct result of the thermocouple
non-linearity.
If you only want to operate over the temperature range 0°C to 1024°C then
the MAX6675 is a good choice (if you accept the error levels) but you can not
use the chip outside this temperature range.
The Thermopile
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 act of
pushing the button is the activation operation for solenoid, so no high power
is needed,just your thumb!. As long as the flame continues the holding current
is generated (thermocouple output) - and the solenoid remains open.
Note: To increase the thermocouple voltage output combine several
thermocouples together to make what is known as a thermopile.
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
]
Thermocouple Examples Uses
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) .
A PIR sensor lets your Arduino sense movement without contact. This tutorial covers PIR sensor basics, connecting one to an Arduino board and coding a motion detector.
Arduino Hall Effect Sensor: Add magnetic sensing superpowers to your Arduino projects with an easy-to-use hall effect sensor. With full code and layout...
Get started with an Arduino humidity sensor using the DHT11, which reports both humidity and temperature. Complete guide with full code for using this sensor
Comments
Have your say about what you just read! Leave me a comment in the box below.
Don’t see the comments box? Log in to your Facebook account, give Facebook consent, then return to this page and refresh it.