# Adafruit MAX31856 Universal Thermocouple Amplifier

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/035/936/medium800/sensors_3263_iso_ORIG.jpg?1474576532)

Thermocouples are very sensitive, requiring a good amplifier with a cold-compensation reference, as well as calculations to handle any non-linearities. For a long time we've suggested our MAX31855K breakout, which works great but is only for K-type thermocouples. Now we're happy to offer a great new thermocouple amplifier/converter that can handle just about _any_ type of thermocouple, and even has the ability to give you notification when the temperature goes out of range, or a fault occurs. Very fancy!

This converter communicates over 4-wire SPI and can interface with any **K** , **J** , **N** , **R** , **S** , **T** , **E** , or **B** type thermocouple

![](https://cdn-learn.adafruit.com/assets/assets/000/035/937/medium800/sensors_thumvb.jpg?1474576549)

This breakout does everything for you, and can be easily interfaced with any microcontroller, even one without an analog input. This breakout board has the chip itself, a 3.3V regulator and level shifting circuitry, all assembled and tested. Comes with a 2 pin terminal block (for connecting to the thermocouple) and pin header (to plug into any breadboard or perfboard). We even added inline resistors and a filter capacitor onboard for better stability, as recommended by Maxim. [Goes great with our 1m K-type thermocouple](http://www.adafruit.com/products/270) or any other thermocouple, really!

- Works with any **K** , **J** , **N** , **R** , **S** , **T** , **E** , or **B** type thermocouple
- **-210°C to +1800°C output in 0.0078125° resolution** - note that many thermocouples have about ±2°C to ±6°C accuracy or worse depending on the temperature and type, so the resolution will be a lot better than the accuracy!
- Internal temperature reading
- 3.3 to 5v power supply and logic level compliant!
- SPI data requires any 4 digital I/O pins.

![](https://cdn-learn.adafruit.com/assets/assets/000/035/938/medium800/sensors_3263_quarter_ORIG.jpg?1474576569)

# Adafruit MAX31856 Universal Thermocouple Amplifier

## Pinouts

![](https://cdn-learn.adafruit.com/assets/assets/000/035/939/medium800/sensors_pinut.jpg?1474576723)

## Power Pins:

- **Vin** - this is the power pin. Since the sensor chip uses 3 VDC, we have included a voltage regulator on board that will take 3-5VDC and safely convert it down. To power the board, give it the same power as the logic level of your microcontroller - e.g. for a 5V micro like Arduino, use 5V
- **3Vo** - this is the 3.3V output from the voltage regulator, you can grab up to 100mA from this if you like
- **GND** - common ground for power and logic

# SPI Logic pins:

All pins going into the breakout have level shifting circuitry to make them 3-5V logic level safe. Use whatever logic level is on **Vin!**

- **SCK** - This is the **S** PI **C** loc **k** pin, its an input to the chip
- **SDO** - this is the **S** erial **D** ata **O** ut / **M** icrocontroller **I** n **S** ensor **O** ut&nbsp;pin, for data sent from the MAX31856 to your processor
- **SDI** - this is the **S** erial **D** ata **I** n / **M** icrocontroller **O** ut **S** ensor **I** n&nbsp;pin, for data sent from your processor to the MAX31856
- **CS** - this is the **C** hip **S** elect pin, drop it low to start an SPI transaction. Its an input to the chip

If you want to connect multiple MAX31856's to one microcontroller, have them share the SDI, SDO and SCK pins. Then assign each one a unique CS pin.

# Additional Pins

There's two more pins that are available for advanced usage

- **FLT** - This is the **Fault** output. If you use the threshhold-notification capabilities of the MAX31856 you can monitor this pin, when it goes low there's a fault!
- **DRDY** - This pin is used for advanced uses where you tell the sensor to begin a reading and then wait for this pin to go low. We don't use it in our library code because we keep it simple with a delay/wait, but it is available in case you need it!

# Adafruit MAX31856 Universal Thermocouple Amplifier

## Assembly

## Prepare the header strip:

&nbsp;

Cut the strip to length if necessary. It will be easier to solder if you insert it into a breadboard - **long pins down.**

![sensors_DSC_3395.jpg](https://cdn-learn.adafruit.com/assets/assets/000/036/064/medium640/sensors_DSC_3395.jpg?1474910096)

## Add the breakout board:

&nbsp;

Place the breakout board over the pins so that the short pins poke through the breakout pads

![sensors_DSC_3397.jpg](https://cdn-learn.adafruit.com/assets/assets/000/036/065/medium640/sensors_DSC_3397.jpg?1474910117)

## And Solder!

&nbsp;

Be sure to solder all 5 pins for reliable electrical contact.

_(For tips on soldering, be sure to check out our_[_Guide to Excellent Soldering_](http://learn.adafruit.com/adafruit-guide-excellent-soldering)_)_

![sensors_DSC_3399.jpg](https://cdn-learn.adafruit.com/assets/assets/000/036/066/medium640/sensors_DSC_3399.jpg?1474910143)

![sensors_DSC_3401.jpg](https://cdn-learn.adafruit.com/assets/assets/000/036/067/medium640/sensors_DSC_3401.jpg?1474910158)

![sensors_DSC_3404.jpg](https://cdn-learn.adafruit.com/assets/assets/000/036/068/medium640/sensors_DSC_3404.jpg?1474910178)

Now you can do the terminal block, this is what you'll use to attach the thermocouple since you cannot solder to thermocouples

The terminal block goes on the top with the open ends pointing out

![sensors_DSC_3405.jpg](https://cdn-learn.adafruit.com/assets/assets/000/036/069/medium640/sensors_DSC_3405.jpg?1474910194)

Solder the two pads as you did with the plain header. They're quite large and require a lot of solder

![sensors_DSC_3408.jpg](https://cdn-learn.adafruit.com/assets/assets/000/036/070/medium640/sensors_DSC_3408.jpg?1474910227)

![sensors_DSC_3410.jpg](https://cdn-learn.adafruit.com/assets/assets/000/036/071/medium640/sensors_DSC_3410.jpg?1474910236)

![sensors_DSC_3411.jpg](https://cdn-learn.adafruit.com/assets/assets/000/036/072/medium640/sensors_DSC_3411.jpg?1474910263)

Insert the thermocouple wires and tighten down the clamps with a small Phillips or flat screwdriver

![sensors_DSC_3412.jpg](https://cdn-learn.adafruit.com/assets/assets/000/036/073/medium640/sensors_DSC_3412.jpg?1474910306)

![sensors_DSC_3416.jpg](https://cdn-learn.adafruit.com/assets/assets/000/036/074/medium640/sensors_DSC_3416.jpg?1474910324)

That's it! you are now ready to wire and test

![sensors_DSC_3422.jpg](https://cdn-learn.adafruit.com/assets/assets/000/036/075/medium640/sensors_DSC_3422.jpg?1474910361)

# Adafruit MAX31856 Universal Thermocouple Amplifier

## Wiring & Test

You can easily wire this breakout to any microcontroller, we'll be using an Arduino. For another kind of microcontroller, as long as you have 4 available pins it is possible to 'bit-bang SPI' or you can use hardware SPI if you like. Just check out the library, then port the code.

![](https://cdn-learn.adafruit.com/assets/assets/000/035/940/medium800/sensors_diagram_bb.png?1474582031)

[Fritzing diagram.fzz](https://cdn-learn.adafruit.com/assets/assets/000/035/941/original/diagram.fzz?1474582047)
# SPI Wiring

Since this is a SPI-capable sensor, we can use hardware or 'software' SPI. To make wiring identical on all Arduinos, we'll begin with 'software' SPI. The following pins should be used:

- Connect **Vin** to the power supply, 3V or 5V is fine. Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V
- Connect **GND** to common power/data ground
- Connect the **SCK** pin to **Digital #13** but any pin can be used later
- Connect the **SDO** pin to **Digital #12** but any pin can be used later
- Connect the **SDI** pin to **Digital #11** but any pin can be used later
- Connect the **CS** pin **Digital #10** but any pin can be used later

Later on, once we get it working, we can adjust the library to use hardware SPI if you desire, or change the pins to other

# Download Adafruit\_MAX31856 library

To begin reading sensor data, you will need to install&nbsp; **Adafruit MAX31856&nbsp;** from the Arduino library manager.

Open up the Arduino library manager:

![](https://cdn-learn.adafruit.com/assets/assets/000/084/393/medium800/sensors_library_manager_menu.png?1573953996)

Search for the&nbsp; **Adafruit MAX31856** library and install it

![](https://cdn-learn.adafruit.com/assets/assets/000/084/395/medium800/sensors_max31856.png?1573954092)

We also have a great tutorial on Arduino library installation at:  
http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use

# Attach Thermocouple

You'll need to attach a thermocouple, for this demo we'll be using a K-type but you can adjust the demo if you do not have a K-type handy!

![](https://cdn-learn.adafruit.com/assets/assets/000/035/943/medium800/sensors_3263_top_demo_ORIG.jpg?1474582713)

# Load Demo

Open up **File-\>Examples-\>Adafruit\_MAX31856**** -\>max31856** and upload to your Arduino wired up to the sensor. Adjust the `max.setThermocoupleType(MAX31856_TCTYPE_K)` line if necessary.

![](https://cdn-learn.adafruit.com/assets/assets/000/035/949/medium800/sensors_demo.png?1474585205)

Upload to your Arduino and open up the serial console at 115200 baud to see a print out of the _cold junction temperature_ (temperature of the microcontroller chip) and the _thermocouple temperature_ (temperature detected at the end of the thermocouple probe

![](https://cdn-learn.adafruit.com/assets/assets/000/035/944/medium800/sensors_themotest.png?1474582802)

You can also see some of the faults that are detectable by say disconnecting one of the pins:

![](https://cdn-learn.adafruit.com/assets/assets/000/035/945/medium800/sensors_fault.png?1474582855)

# Library Reference

You can start out by creating a MAX31856 object with either software SPI (where all four pins can be any I/O) using

```
// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31856 max = Adafruit_MAX31856(10, 11, 12, 13);
```

Or you can use hardware SPI. With hardware SPI you _must_ use the hardware SPI pins for your Arduino - and each arduino type has different pins! [Check the SPI reference to see what pins to use.](http://arduino.cc/en/Reference/SPI)  
In this case, you can use any CS pin, but the other three pins are fixed

```
// use hardware SPI, just pass in the CS pin
Adafruit_MAX31856 max = Adafruit_MAX31856(10);
```

Once started, you can initialize the sensor with

```
max.begin()
```

You'll also need to set the thermocouple type, remember there's a lot of options! Set the type with:

```
max.setThermocoupleType(MAX31856_TCTYPE_xxx)
```

Your options for the _TCTYPE_ are:

- `MAX31856_TCTYPE_B`
- `MAX31856_TCTYPE_E`
- `MAX31856_TCTYPE_J`
- `MAX31856_TCTYPE_K`
- `MAX31856_TCTYPE_N`
- `MAX31856_TCTYPE_R`
- `MAX31856_TCTYPE_S`
- `MAX31856_TCTYPE_T`
- `MAX31856_VMODE_G8`
- `MAX31856_VMODE_G32`

The last two are not thermocouple types, they're just 'plain' voltage readings (check the datasheet for more details, we don't use these modes in the library)

If you're ever not sure which mode you're in, query it with

```
max.getThermocoupleType()
```

Once that's set you can read the cold junction temperature, which will return a floating point Celsius reading. This is the temperature detected inside the MAX31856 chip ('ambient' temp)

```
max.readCJTemperature()
```

Or, of course, the temperature at the end/tip of the thermocouple, likewise a floating point #

```
max.readThermocoupleTemperature()
```

### Faults

The MAX31856 has a wide-ranging fault mechanism that can alert you via pin or function when something is amiss. Don't forget to test this functionality before relying on it!

You can read faults with

```
 max.readFault()
```

Which will return a uint8\_t type with bits set for each of 8 different fault types. You can test for each one with this set of code:

```
  uint8_t fault = max.readFault();
  if (fault) {
    if (fault &amp; MAX31856_FAULT_CJRANGE) Serial.println("Cold Junction Range Fault");
    if (fault &amp; MAX31856_FAULT_TCRANGE) Serial.println("Thermocouple Range Fault");
    if (fault &amp; MAX31856_FAULT_CJHIGH)  Serial.println("Cold Junction High Fault");
    if (fault &amp; MAX31856_FAULT_CJLOW)   Serial.println("Cold Junction Low Fault");
    if (fault &amp; MAX31856_FAULT_TCHIGH)  Serial.println("Thermocouple High Fault");
    if (fault &amp; MAX31856_FAULT_TCLOW)   Serial.println("Thermocouple Low Fault");
    if (fault &amp; MAX31856_FAULT_OVUV)    Serial.println("Over/Under Voltage Fault");
    if (fault &amp; MAX31856_FAULT_OPEN)    Serial.println("Thermocouple Open Fault");
  }
```

The last two faults are built in. For the low/high threshholds, you can set those with two functions.

For the cold junction (chip) temp, use:

```
max.setColdJunctionFaultThreshholds(lowtemp, hightemp)
```

Where _lowtemp_ and _hightemp_ range between -127 and +127 Centigrade (the chip wont function down to -127 but that's the lowest number you can put in.

For the thermocouple, use

```
setTempFaultThreshholds(lowtemp, hightemp)
```

Where lowtemp and hightemp are floating point numbers with a range of -4096 to +4096 and a resolution of 0.0625 degrees Centigrade

![](https://cdn-learn.adafruit.com/assets/assets/000/084/393/medium800/sensors_library_manager_menu.png?1573953996)

# Adafruit MAX31856 Universal Thermocouple Amplifier

## Python & CircuitPython

It's easy to use the MAX31856 sensor with Python and CircuitPython, and the&nbsp;[Adafruit CircuitPython MAX31856](https://github.com/adafruit/Adafruit_CircuitPython_MAX31856)&nbsp;module.&nbsp; This module allows you to easily write Python code that reads the&nbsp;temperature from the thermocouple.

You can use this sensor with any CircuitPython microcontroller board or with a computer that has GPIO and Python [thanks to Adafruit\_Blinka, our CircuitPython-for-Python compatibility library](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).

## CircuitPython Microcontroller Wiring

First, wire up a MAX31856 to your board exactly as shown on the previous pages for Arduino.&nbsp; Here's an example of wiring a Feather M0 to the sensor:

- **Board 3V** &nbsp;to&nbsp; **sensor VIN**
- **Board GND** &nbsp;to&nbsp; **sensor GND**
- **Board SCK** &nbsp;to&nbsp; **sensor SCK**
- **Board MISO** &nbsp;to&nbsp; **sensor SDO**
- **Board MOSI** to&nbsp; **sensor SDI**
- **Board D5** to **sensor CS** (or any other free digital I/O pin)

![sensors_MAX31856_Feather_M0_SPI_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/082/229/medium640/sensors_MAX31856_Feather_M0_SPI_bb.png?1570818318)

Once wired to the microcontroller, make sure you connect a thermocouple to the terminal on the breakout board.

## Python Computer Wiring

Since there's _dozens_ of Linux computers/boards you can use, this shows wiring for Raspberry Pi. For other platforms, [please visit the guide for CircuitPython on Linux to see whether your platform is supported](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).&nbsp;

Here's the Raspberry Pi wired with SPI:

- **Pi 3V** &nbsp;to&nbsp; **sensor VIN**
- **Pi GND** &nbsp;to&nbsp; **sensor GND**
- **Pi SCK** &nbsp;to&nbsp; **sensor SCK**
- **Pi MISO** &nbsp;to&nbsp; **sensor SDO**
- **Pi MOSI** to&nbsp; **sensor SDI**
- **Pi D5** to **sensor CS** (or any other free digital I/O pin)

![sensors_MAX31856_Raspi_SPI_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/096/093/medium640/sensors_MAX31856_Raspi_SPI_bb.jpg?1603119850)

Once wired to the Raspberry Pi, make sure you connect a thermocouple to the terminal on the breakout board.

## CircuitPython Installation of MAX31856 Library

Next, you'll need to install the [Adafruit CircuitPython MAX31856](https://github.com/adafruit/Adafruit_CircuitPython_MAX31856)&nbsp;library on your CircuitPython board

First, make sure you are running the [latest version of Adafruit CircuitPython](https://github.com/adafruit/circuitpython/releases)&nbsp;for your board.

Next you'll need to install the necessary libraries to use the hardware. Carefully follow the steps to find and install these libraries from [Adafruit's CircuitPython library bundle](https://circuitpython.org/libraries).&nbsp; For example the Circuit Playground Express guide has&nbsp;[a great page on how to install the library bundle](https://learn.adafruit.com/adafruit-circuit-playground-express/installing-libraries) for both Express and non-Express boards.

Remember for non-Express boards like the Trinket M0, Gemma M0, and Feather/Metro M0 basic you'll need to manually install the necessary libraries from the bundle:

- **adafruit\_max31856.mpy**
- **adafruit\_bus\_device**

Before continuing, make sure your board's **lib** folder has the **adafruit\_max31856.mpy,** and **&nbsp;adafruit\_bus\_device**** &nbsp; **files and folders** &nbsp;**copied over.

Next[&nbsp;connect to the board's serial REPL](https://learn.adafruit.com/welcome-to-circuitpython/the-repl) so you are at the CircuitPython&nbsp; **\>\>\>** &nbsp;prompt.

## Python Installation of MAX31856 Library

You'll need to install the **Adafruit\_Blinka** library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3. [Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux)!

Once that's done, from your command line run the following command:

- `sudo pip3 install adafruit-circuitpython-max31856`

If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

## CircuitPython & Python Usage

To demonstrate the usage of the sensor, initialize it and read the temperature.&nbsp; Remember to attach a thermocouple to the terminal on the breakout!

First initialize the SPI connection and library by running:

```python
import board
import digitalio
import adafruit_max31856
spi = board.SPI()
cs = digitalio.DigitalInOut(board.D5)
cs.direction = digitalio.Direction.OUTPUT
thermocouple = adafruit_max31856.MAX31856(spi,cs)
```

Now you can read the&nbsp; **temperature** &nbsp;property to retrieve the temperature from the sensor in degrees Celsius:

```python
print(thermocouple.temperature)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/082/231/medium800/sensors_MAX31856_REPL_Output.png?1570818585)

That's all there is to reading temperature with the MAX31856 and CircuitPython code!

## Full Example Code
https://github.com/adafruit/Adafruit_CircuitPython_MAX31856/blob/main/examples/max31856_simpletest.py

# Adafruit MAX31856 Universal Thermocouple Amplifier

## Python Docs

# Adafruit MAX31856 Universal Thermocouple Amplifier

## Downloads

# Files

- [Fritzing object in Adafruit Fritzing library](https://github.com/adafruit/Fritzing-Library/)
- [EagleCAD PCB files on GitHub](https://github.com/adafruit/Adafruit-MAX31856-PCB)
- [Library on GitHub](https://github.com/adafruit/Adafruit_MAX31856)
- [MAX31856 Datasheet](https://cdn-learn.adafruit.com/assets/assets/000/035/948/original/MAX31856.pdf)

# Schematic
![](https://cdn-learn.adafruit.com/assets/assets/000/035/946/medium800/sensors_schem.png?1474583748)

# Fabrication Print
![](https://cdn-learn.adafruit.com/assets/assets/000/103/588/medium800/sensors_MAX31856_fab_print.png?1627310999)


## Featured Products

### Thermocouple Type-K Glass Braid Insulated

[Thermocouple Type-K Glass Braid Insulated](https://www.adafruit.com/product/270)
Thermocouples are best used for measuring temperatures that can go above 100 °C. This is a bare wires bead-probe which can measure air or surface temperatures. Most inexpensive thermocouples have a vinyl covering which can melt at around 200 °C, this one uses a fiberglass braid so it...

In Stock
[Buy Now](https://www.adafruit.com/product/270)
[Related Guides to the Product](https://learn.adafruit.com/products/270/guides)
### Adafruit Universal Thermocouple Amplifier MAX31856 Breakout

[Adafruit Universal Thermocouple Amplifier MAX31856 Breakout](https://www.adafruit.com/product/3263)
Thermocouples are very sensitive, requiring a good amplifier with a cold-compensation reference, as well as calculations to handle any non-linearities. For a long time we've [suggested our MAX31855K breakout, which works great but is only for...](https://www.adafruit.com/products/269)

Out of Stock
[Buy Now](https://www.adafruit.com/product/3263)
[Related Guides to the Product](https://learn.adafruit.com/products/3263/guides)

## Related Guides

- [MAX31855 Thermocouple](https://learn.adafruit.com/thermocouple.md)
- [Bluetooth Cycling Speed & Cadence Sensor Display with Clue](https://learn.adafruit.com/bluetooth-bicycle-speed-cadence-sensor-display-with-clue.md)
- [Adafruit TMP007 Sensor Breakout](https://learn.adafruit.com/adafruit-tmp007-sensor-breakout.md)
- [Use Apple HomeKit Devices with itsaSNAP and Adafruit IO](https://learn.adafruit.com/use-apple-homekit-devices-with-itsasnap.md)
- [Cloud-Connected Weather Station with the Arduino Yun & Temboo](https://learn.adafruit.com/cloud-connected-weather-station-with-the-arduino-yun-and-temboo.md)
- [Working with Multiple Same Address I2C Devices](https://learn.adafruit.com/working-with-multiple-i2c-devices.md)
- [Adafruit HTS221 - Temperature & Humidity Sensor](https://learn.adafruit.com/adafruit-hts221-temperature-humidity-sensor.md)
- [PyLeap CLUE Sensor Plotter](https://learn.adafruit.com/pyleap-clue-sensor-plotter.md)
- [MPU6050 6-DoF Accelerometer and Gyro](https://learn.adafruit.com/mpu6050-6-dof-accelerometer-and-gyro.md)
- [MP3 Playback on RP2040 with CircuitPython](https://learn.adafruit.com/mp3-playback-rp2040.md)
- [IoT Filament Sensor](https://learn.adafruit.com/iot-filament-sensor.md)
- [Digi-Key IoT Studio Mini Smart Home](https://learn.adafruit.com/digikey-iot-studio-smart-home.md)
- [Talking Computer from Star Trek](https://learn.adafruit.com/talking-computer-from-star-trek.md)
- [MLX90393 Wide-Range 3-Axis Magnetometer](https://learn.adafruit.com/mlx90393-wide-range-3-axis-magnetometer.md)
- [LSM303 Accelerometer + Compass Breakout](https://learn.adafruit.com/lsm303-accelerometer-slash-compass-breakout.md)
- [Funhouse Door Alert with Email Notification](https://learn.adafruit.com/funhouse-door-alert-email-notification.md)
