Source: https://mokxi.com/learn/arduino-max31855

Learn

# A MAX31855 on an Arduino: a thermocouple for a kiln

Intermediate

Written by the Mokxi team

Start building free Open the editor

Or see every lesson.

- 455 parts on the bench
- 43 boards running now
- 1.00x real time, on every board

Click to open it in the editor

The Kiln and bath probes example: a K-type thermocouple on a MAX31855 and a PT100 on a MAX31865. Drag either slider.

A K-type thermocouple can measure from far below freezing to well over 1000 C, which is why it is the probe in kilns, forges, smokers and 3D printer hot ends. On its own it gives a few millivolts. The MAX31855 board turns that into a temperature an Arduino can read over three wires.

The circuit above is an Uno with two probes, as for a pottery kiln and the glaze bath beside it: a thermocouple on a MAX31855 for the kiln, and a PT100 platinum probe on a MAX31865 for the bath, where a tenth of a degree matters. Press Run, then drag the thermocouple slider past 1000 C and watch the sketch call the kiln ready.

## What you need

- An Arduino Uno
- A MAX31855 board with a K-type thermocouple
- A MAX31865 board with a PT100 probe (for the second half)
- Jumper wires

## Wiring

Part and pin | Goes to | Note

MAX31855 VCC and GND | 5 V and GND | The board runs on 3 to 5 V

MAX31855 CLK | Pin 7 | Software SPI: any three pins work

MAX31855 CS | Pin 6 |

MAX31855 DO | Pin 5 | The chip’s data out

MAX31865 CLK, SDO, SDI | Pins 13, 12, 11 | The Uno’s hardware SPI

MAX31865 CS | Pin 10 |

MAX31865 VIN and GND | 5 V and GND |

## How a thermocouple works

A thermocouple is two different metals joined at the tip, chromel and alumel for a K type. Heat the tip and a tiny voltage appears at the other end, about 41 microvolts for every degree of difference between the tip and the cold end where it connects.

That word "difference" is the catch. To know the tip’s temperature you also need the cold end’s, so the MAX31855 has a temperature sensor of its own (the cold junction) and adds it in. The chip does the amplifying, the cold-junction math and the conversion, and hands back the tip in quarter degrees.

## Reading it

The MAX31855 has no data in, only out, so it needs three wires: a clock, a chip select and data out. Adafruit_MAX31855 kiln(7, 6, 5) takes them in that order, CLK, CS, DO, and reads them in software on any pins. readCelsius() gives the tip and readInternal() the board’s own temperature.

The chip converts every 100 ms. Run the circuit and the very first line reads "kiln 0 C board 0.0 C", because it was read before the first conversion was done. Half a second later it says "kiln 850 C board 24.0 C bath 62.5 C". Drag the tip to 1200 and the sketch adds "Kiln at temperature".

The kiln and bath sketch

## Faults, and the one it cannot see

The MAX31855 checks its probe on every reading: an open probe (a broken or unplugged wire), a short to ground and a short to VCC each set a fault bit. When one is set, readCelsius() returns NAN, "not a number", and the sketch prints "kiln fault". Always check with isnan() before using the number, or a broken probe looks like a very strange temperature.

There is one failure the chip cannot report: a loose DO wire. With DO unplugged nothing drives the Uno’s input, so it floats and each reading is whatever the pin picks up. A run of zeros reads as 0 C with no fault bits set, a run of ones as a fault. Pull DO in the circuit above and the sketch prints "kiln 0 C" and "kiln fault" by turns, with the board stuck near 0 C. A board reading near zero in a warm room is the clue.

Unlike the older MAX6675, the MAX31855 reads below freezing. Drag the tip to -5 C and it prints -5. The MAX6675 stops at 0 and tops out at 1024 C; the MAX31855 goes from -200 to 1350 C with a K type, both in quarter degrees.

## The PT100 beside it

A thermocouple reaches far hotter, but it is only good to a couple of degrees. A PT100 is a platinum resistor that is 100 ohms at 0 C and rises in a very exact way as it warms. The MAX31865 measures it against a 430 ohm reference resistor on its board, which is what bath.temperature(100.0, 430.0) passes in: the probe’s nominal value and the reference.

The MAX31865 talks full SPI, with data both ways, so it uses the Uno’s hardware SPI pins 11, 12 and 13 and its own chip select on pin 10. The bath reads 62.5 C here, to a tenth of a degree.

Note what this short sketch does not do: check the RTD for faults. Break the PT100’s wire in the circuit and the bath reads 988.8 C. A real controller calls bath.readFault() and stops the heater on anything but 0.

## Common mistakes

Using the number without checking isnan(). A broken probe returns NAN, and NAN compared to anything is false, so a heater control can stay on.

Thermocouple wires on the wrong screws. Swap the red and yellow leads of a K type and the reading goes the wrong way when the tip heats. On US-colored probes, red is the negative lead.

Extending the probe with plain copper wire. The extra junctions add errors; use K-type extension wire.

Reading faster than ten times a second. The value only changes every 100 ms.

Wiring DO to the Uno’s MOSI pin because of the SPI name. DO is the chip’s output and goes to an input.

## Questions

What is the difference between the MAX6675 and the MAX31855?

The MAX31855 reads below 0 C, goes up to 1350 C instead of 1024, and tells you which of three faults it found. The MAX6675 is older and only flags an open probe. Both read in quarter degrees.

Which pins does the MAX31855 need?

Three: CLK, CS and DO, plus power and ground. The Adafruit library can use any three digital pins, or the hardware SPI pins if you pass only CS.

Why does my MAX31855 read NAN?

A fault: usually the thermocouple is unplugged or a lead is broken (open circuit), or a lead touches ground or the supply. Call readError() to see which bit is set.

Thermocouple or PT100?

A thermocouple for heat past about 500 C or a fast, cheap probe; a PT100 for accuracy to a fraction of a degree in the range people live and cook in.

Related

## Keep going

Arduino MAX6675 Thermocouple: Wiring and Code SPI Explained: Clock, Data and Chip Select Arduino 10k Thermistor: Wiring and Code Arduino DS18B20 Temperature Sensor: Wiring and Code 3D Printer Firmware: Homing, PID, G-code, Runout How the MAX31855 is modeled How the MAX31865 and its PT100 are modeled The Arduino Uno simulator The project page, with the full sketch Intermediate

## Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.

Start building free Open the editor
