A Precision Arduino Thermocouple Measuring System

Completed Multi-channel Arduino Thermoucouple Measuring System

A Precision Arduino Thermocouple Measuring System

This post provides Arduino enthusiasts with the technical framework to develop a high quality Arduino Thermocouple measuring system. It also provides the basics to encourage young Arduino users to get a project up and running. We keep the topics as brief as possible to encourage our young friends.  The more advanced topics such as thermocouple linearity, cold junction compensation, ADC range/resolution, filters and calibration will be examined subsequent posts.

Thermocouple Principle of Operation

Structure of the Thermocouple showing two different metal and voltage drop

Fig 1.0 . Structure of the Thermocouple

To understand the Arduino thermocouple data-acquisition system, we must first look at some basics. Thermocouples are typically used to measure wide and high temperature ranges .The thermocouple works on the basis of the Seebeck effect.  It is made from joining two dissimilar metals together in a loop. When two dissimilar metals are joined together in a loop and the two junctions are held at different temperatures, an electromotive force (EMF) or voltage is developed across the wires. The voltage is proportional to the temperature difference between the two junctions. As a result we do not get an absolute temperature measurement from the thermocouple. Also the voltage is not developed at the junction. Welded joints are preferred over twisted joint due to the resulting robust electrical contact.



What is the Seebeck coefficient?

Seebeck Coefficient Thermocouple Example

Fig. 2.0. Seebeck Coefficient Thermocouple Example

The Seebeck coefficient tells us the magnitude of the voltage across a wire for every degree difference in temperature at the ends. It also tells us the polarity of the voltage. For example a wire made from the alloy Constantant with one end held at 100℃ and the other end held at 36℃will produce a voltage of approximately -2240 uV . A wire made of the alloy Nichrome under the same conditions will produce a voltage of approx. +1600 uV. Note the polarity difference. The ends that are joined are called the hot junction. The hot junction is typically for the temperature to be measured. The cold junction is the two terminals that connect to the instrument. The cold junction is normally referred to as the reference junction. Adding the differential voltages of both wire results in 1600+2240=3840 uV . The total Seebeck coefficient of this arrangement is 60 uV/℃.

Using NIST Thermocouple Table

 Example of using the E type thermocouple table

Fig. 3.0. Example: Using the E type Thermocouple Table

The National Institute of Standards and Technology (NIST) provides 2 tables which lists the output voltages of the K-, J-, N-, T-, S-, R-, or E-type thermocouples. The first table lists the values for -270℃  to 0 ℃  in increments of one degree. The second table provides output voltages from 0℃  to 1000℃ for each thermocouple . For example the output voltage of an E type thermocouple at differential temperature of  -122 ℃   will output -6.191 mV. As shown, using the fist column to find -120 ℃  and then moving horizontally in the same row to 4th column under -2 we reach -122℃ temperature which will have a differential voltage at the cold junction of  -6.191 uV. Another way of finding the output voltage is by using the equation which we will discuss in another post.

Temperature Range and Resolution

Temperature and output voltage range of typical thermocouple

Fig. 4.0. Temperature and Voltage Range

The first important design requirement is the temperature range that the device has to measure. Typical temperature ranges of thermocouples are listed in this figure. The ranges of the voltage at the terminals are also shown.

The resolution of the measurement is dependent on the resolution of the analog to digital converter (ADC). With an 8 bit ADC operating at the full range of a K type thermocouple for example, will result in increment of \frac{1250 -(-200 ℃)}{2^8} =5.7 ℃. Higher resolution is achieved by increasing the resolution of the ADC. For example with a 14 bit ADC we will get a resolution of \frac{1250 -(-200 ℃)}{2^{14}} =0.1 ℃.

Note that the resolution of the ADC mentioned above is the absolute minimum for the ADC. This does not include thermocouple ADC non-linearity and other ADC imperfections.

Cold Junction Compensation

With our previous example, the temperature at the hot junction can be solved if we know (1) the type of thermocouple, (2) the differential voltage at the end of the wires and (3) the temperature at the cold junction. The temperature at the cold junction can be measured with absolute temperature sensors such as semiconductor temperature sensor, Resistance temperature detectors (RTD’s) or other low temperature sensors connected to the Arduino analog to digital converter (ADC).  It is worthwhile however to note that the accuracy and resolution of the system also depends on the accuracy and resolution of the cold junction measurement as well as the hot junction. With the cold junction temperature known, we can then solve for the hot junction by measuring the differential voltage with another ADC and calculate the unknown hot junction temperature.

The Low Temperature Sensor

Selecting the type of temperature sensor that will measure the cold junction requires knowledge of the operating environment or ambient conditions. For example, choosing the popular TMP36 Arduino Low Voltage Temperature Sensor from Analog devices will result in operating environment range of −40°C to +125°C. This has a wider operating range than the Atmel microcontrollers on the Arduino which are typically specified between -40  to 85°C.

Typical Single Channel Arduino Thermocouple System

Complete Arduino Thermocouple System

Fig. 5.0. Complete Arduino Thermocouple System

Now we can look at the typical Arduino thermocouple system show in  figure 5.0. The hot junction which is shown on the left is the thermocouple tip. As the thermocouple lead enters the enclosure it mates with the cold junction temperature sensor. The thermocouple’s differential voltage and cold junction is measured by ADC’s 1 and 2. To simplify the system we show 2 ADCs ; however,  one ADC is typically used and the two measurements are multiplexed at the the ADC input. The dotted line shows the boundary between the integrated thermoucouple solution  and the rest of the system. The Arduino communicate with the ADC through the communication interface which can be Serial Peripheral Interface (SPI) or any other interface. The computer connects to the Arduino USB port. The MAX31855 implementation differs from this but the function is the same which is covered next.

MAX31855 Thermocouple to Digital Converter

Single Channel Thermocouple System

Fig. 6.0. Single Channel Thermocouple System

First we explore a single channel thermocouple temperature measuring system. The system is built around the Thermocouple to digital converter MAX31855 chip from Maxim Integrated. This chip includes the thermocouple interface as well as the cold junction components. It comes in different variations to interface with K-, J-, N-, T-, S-, R-, or E-type thermocouple.  The suffix on the part number indicates the type of thermocouple. For example the  MAX31855K is for K type thermocouple whereas MAX31855J is for J type thermocouple. We will be using the K-type Thermocouple in this example. This chip provides a 2 °C accuracy for a temperature range of -200°C to +700 °C. The complete instrument is shown in this figure. The AD-0117 board comes with the electrical as well as the mechanical interface required for building this instrument. The AD-0117 board has 3 communication and 2 power terminals. It also comes with “open”, “ground short” and “vcc short” fault detect. The two position terminal block for the thermocouple is positioned outside the enclosure when mounted. The Arduino reads the temperature and transmits the values to the computer via the USB connection.

MAX31855 Conversion Cycle and Data Format

Conversion Cycle and Data Format

Fig. 7.0. MAX31855 Conversion Cycle and Data Format

When the Max31855 power’s up, it takes 200 ms before the first conversion to start. The temperature to digital conversion cycle consists of three measurement; the cold junction conversion, hot junction conversion and the fault detect test. This entire cycle takes 100 ms. This cycle continues in the background.  The temperature measurement is ready to be clocked out after the first conversion;  However, the first conversion should be discarded. The output data consists of thermocouple measurement bit (31) ” sign bit” and ( bit(31) to bit(18)) total of (13) bits. The cold junction temperature measurement ( bit(15) to bit(4) 12 bits and fault detect (bit(3) to bit(0)).

MAX31855 Communication and Temperature Conversion code

The following is the minimum code needed to communicate with the MAX31855 chip and to convert the data into temperature measurement.

// Arduino IDE rev 1.8.0
// Communicating with the MAX31855 chip
// We are using the SPI port on the Arduino which
// requires the SPI library to be included.
 #include <SPI.h>;
// declare the pin used for chip select on the MAX31855
 const int MAX31855ChipSelect = 10;
// Masks for evaluating fault bits
 const uint8_t TCshortVCC=4;
 const uint8_t TCshortGND=2;
 const uint8_t TCopen=1;

The SPI interface speed should be 5 MHz or less. 
Data is shifted out of the buffer with Most 
Significant Bit First (MSB). The clock pin is 
idle when low and the data on the SO pin is valid
on the falling edge of the clock pin (SCK). This
gives us the parameters for the 1st function in 
the Arduino code.
 SPISettings MAX31855_com_set(5000000, MSBFIRST, SPI_MODE0);
// Pin connections to report faults on the thermocouple (TC).
// Can be modified based on different hardware connections
 int LED_flt_TCshortVCC=13; // The Arduino pin that is connected to the TC "short to VCC" LED
 int LED_flt_TCshortGND=12; // The Arduino pin that is connected to the TC "short to ground" LED
 int LED_flt_TCopen=11; // The Arduino pin that is connected to the TC "open" LED

// The 32 bit data received from the MAX31855 is stored as
// 4 byte array
 uint8_t MaxData[4];// data clocked out of the max chip
// Variables for the (4) byte arrays converted to (2) 16 bits integers 
 uint16_t RJdata=0; // 2 byte reference junction data converted to 16 bit
 uint16_t TCdata=0; // 2 byte thermocouple data converted to 16 bits
 float RJtemp=0; // calculated reference junction temperature
 float TCtemp=0; // calculated thermocouple temperature
 float absTemp=0;// calculated absolute temperature

Initialization code for this project
void setup()
 // Initialize LED connections used for fault indicators 
 // Initialize communication for the MAX chip
  pinMode(MAX31855ChipSelect, OUTPUT); // set the chip select pin as output
 // Delay the SPI communication to allow the to power-up and convert twice
 // The first conversion is discarded
 // Computer interface or temperature display initialization code to be placed here

void loop()
 // setup communication setting for MAX31855 chip
 // Enable the Thermocouple chip to start clocking the data out
 // The output buffer on the chip will not be updated as long as
 // this pin is held low
  digitalWrite(MAX31855ChipSelect, LOW);
 // Reading the converted temperature data from the MAX chip
 // Reading only. Data sent does not matter
  digitalWrite(MAX31855ChipSelect, HIGH);
 // Combine the 2 most significant byte to get the
 // 16 bit thermocouple data
  TCdata = MaxData[0]; // load most significant byte
  TCdata = TCdata<<8; ; // shift to MSB position
  TCdata |= MaxData[1]; // load least significant byte
 // Combine the 2 most significant byte to get the
 // 16 bit reference junction data
  RJdata = MaxData[2]; // load most significant byte
  RJdata = TCdata<<8; // shift to MSB position
  RJdata |= MaxData[3]; // load least significant byte*/
 // extracting fault bits
  uint8_t TCfault=uint8_t(RJdata & uint16_t(7));
 // Fault handler 
 if (TCfault&TCshortVCC) // short circuit to VCC detected
  // VCC short circuit fault indicator code
 else if (TCfault&TCshortGND) // short to ground detected
  // ground short fault indicator code
 else if (TCfault&TCopen) // open circuit detected
  // open circuit fault indicator code
  // mapping to temperature is done separately for clarity

 // evaluate temperature
 if (TCfault==0) // if there are no faults
  // clear all fault indicators
  if (((TCdata & bit(15)) == bit(15))) // if temperature is negative
   // converting thermocouple data to temperature
   TCdata-~TCdata; // compliment
   TCdata=TCdata>>2; // right shift by 2
   // converting cold junction data to temperature
   RJdata=(RJdata,15); //set MSB
   RJdata=~RJdata; // compliment
   RJdata=RJdata>>3; // right shift by 3
 }else{ // if temperature is positive
   TCdata=TCdata>>2; // right shift by 2
   RJdata=RJdata>>3; // right shift by 3
  absTemp=TCtemp-RJtemp; // calculate absolute temperature

// Computer interface or temperature display code to be placed here



We would like your feedback on this post. If you notices errors or have questions please feel free to contact us.

Related products

Single and Dual channel Arduino Thermocouple Breakout Board

Arduino Dual Thermocouple breakout board example terminal block

Arduino Dual Thermocouple breakout board example terminal block

Arduino Thermocouple breakout board in enclosure example

Single and Dual channel Arduino Thermocouple breakout board

These Arduino Thermocouple Breakout Board are designed to be mounted in enclosures. Connection to the thermocouple leads are provided via terminal blocks. These thermocouple breakout boards are available in single and dual channel. The Serial Peripheral Interface (SPI) port is equipped with input and output connectors. This provides daisy chaining many boards on a single SPI port.

Arduino LED Breakout Board

solid color Arduino breakout board family

solid color Arduino breakout board family

Arduino LED Breakout Board product line includes many different designs. The boards are designed to be very versatile. The boards can be configured with solid color and RGB LEDs. The LEDs are Charlieplexed to reduce the number of the pins used on the Arduino. The form factors include terminal block versions and header versions. The terminal block versions are used during prototyping and header versions that are used during production. These boards come with in multiple rows and columns LEDs. The LED numbering system starts at the lower left corner and proceeds to the right on the first row. on the second row the number continues at the left most LED.

Custom Arduino Enclosure

The Custom Arduino Enclosure  for specific projects includes free design changes.


Custom Arduino Enclosure with Window, RJ45 and DB9 connector

Custom Arduino Enclosure with Window, RJ45 and DB9 connector