Source: https://mokxi.com/libraries/adafruit-max31855
Updated: 2026-11-22

Libraries / Sensors

Arduino library · Sensors

# Adafruit MAX31855: a K-type thermocouple from -200 to 1350 °C

Yes. You can use the Adafruit MAX31855 library online in Mokxi with nothing to install, and the sketch runs in your browser against the simulated part (Thermocouple converter, MAX31855). The example below, "A K-type thermocouple on a MAX31855, on any three pins", runs on the Arduino Uno R3.

Run the example in Mokxi See the calls

Built in on Mokxi: #include <Adafruit_MAX31855.h> and it builds, with nothing to install. Free, and no account needed.

## What Adafruit MAX31855 does

A thermocouple makes a few microvolts per degree, far too little for an analog pin, so a converter chip does the work. The MAX31855 is Maxim’s newer one for K-type probes: it reads from -200 to 1350 °C in quarter-degree steps, compensates for the temperature of its own terminals, and sends the result as a 32-bit word over a read-only SPI link. Adafruit_MAX31855 reads that word and hands you degrees.

Next to the MAX6675 the difference is range and diagnosis. The MAX6675 stops at 0 °C at the bottom and 1024 °C at the top and reports only an open probe. The MAX31855 also reads below freezing, gives you the chip’s own temperature with readInternal(), and tells three faults apart: probe open, shorted to ground, or shorted to VCC. On any fault readCelsius() returns NAN, which is why the example checks isnan().

The library works on hardware SPI or any three pins in software, and the example uses software SPI with CLK on pin 2, CS on pin 3 and DO on pin 4. The thermocouple part in Mokxi has a temperature and an ambient you can set, so you can watch both readings and try a fault without a hot plate.

Library Manager name | Adafruit MAX31855

Author | Adafruit

Include | #include <Adafruit_MAX31855.h>

Boards | every board Mokxi compiles for but ATtiny85

In the simulator | Simulated: it runs against the part the way it does on the bench.

Parts it drives | Thermocouple converter, MAX31855

## Install it

It builds on every board Mokxi compiles for but ATtiny85.

In Mokxi it is built in: #include <Adafruit_MAX31855.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "Adafruit MAX31855" by Adafruit from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add Adafruit MAX31855 to lib_deps in PlatformIO. Mokxi follows the calls of release 1.4.2, so a sketch written here builds there too.

- ESP32-C3
- Arduino Uno
- Arduino Nano
- Arduino Mega 2560
- Arduino Leonardo
- SparkFun Pro Micro
- Arduino Micro
- ESP32-C6
- WCH CH32V003
- Raspberry Pi Pico
- Raspberry Pi Pico W
- Seeed XIAO SAMD21
- STM32
- STM32 Nucleo-F411RE
- STM32 Blue Pill
- micro:bit V2
- Arduino Uno R4
- ESP32 DevKit
- ESP32-S3-DevKitC-1
- ESP8266 NodeMCU
- Arduino Pro Mini 3.3 V
- Seeed XIAO ESP32-C3
- ESP32-C3 SuperMini
- Seeed XIAO ESP32-C6
- ESP32-DevKitC V4
- LOLIN32 Lite
- Wemos D1 R32
- Cheap Yellow Display
- TTGO T-Display
- Seeed XIAO ESP32-S3
- ESP32-S3-CAM
- Arduino Nano ESP32
- Arduino Nano RP2040 Connect
- Seeed XIAO RP2040
- Waveshare RP2040-Zero
- Arduino Uno R4 WiFi

## The calls you will use

In the order a sketch meets them.

### Adafruit_MAX31855 thermocouple(MAXCLK, MAXCS, MAXDO)

The chip on three pins of your choosing, in software SPI. Passing only the CS pin uses the hardware SPI bus.

### thermocouple.begin()

Sets the pins up and returns true. Call it once, after a short delay so the chip has finished its first conversion.

### thermocouple.readCelsius()

The probe’s temperature in °C as a double, or NAN when a fault is set.

### thermocouple.readInternal()

The chip’s own temperature, which is the cold junction it compensates for. Handy as a room thermometer.

### thermocouple.readFahrenheit()

The probe temperature in °F, also NAN on a fault.

### thermocouple.readError()

The fault bits: MAX31855_FAULT_OPEN, MAX31855_FAULT_SHORT_GND and MAX31855_FAULT_SHORT_VCC, or 0 when all is well.

### thermocouple.setFaultChecks(MAX31855_FAULT_OPEN)

Chooses which faults make readCelsius() return NAN. Leave out the short checks if your probe is grounded on purpose.

## Example: A K-type thermocouple on a MAX31855, on any three pins

On the Arduino Uno R3. It runs in the browser exactly as printed.

sketch.ino · Arduino Uno R3

### Wiring

- Arduino Uno R3 2 to Thermocouple converter, MAX31855 CLK
- Arduino Uno R3 3 to Thermocouple converter, MAX31855 CS
- Arduino Uno R3 4 to Thermocouple converter, MAX31855 DO
- Arduino Uno R3 5V to Thermocouple converter, MAX31855 VCC
- Arduino Uno R3 GND to Thermocouple converter, MAX31855 GND

Open it in the editor, wired and ready to run

## Common errors and how to fix them

### Thermocouple fault(s) detected! on every reading

The probe is not connected, or is shorted to the case. Check both wires in the screw terminal, then call readError(): 1 is open, 2 a short to ground and 4 a short to VCC.

### The temperature falls when the probe is heated

The thermocouple wires are swapped. On a K-type the red lead is usually negative; swap the two wires at the terminal block.

### Readings jump by tens of degrees near a motor or relay

The tiny thermocouple voltage picks up noise. Keep the probe leads away from power wires, add a 10 nF capacitor across the inputs, and average a few readings.

## Questions and answers

### Can I use the MAX31855 with a J-type or T-type probe?

Only with the chip made for that type. The MAX31855K is for K-type; other letters (J, N, T, E, R, S) are separate chips that the same library reads.

## Projects that use Adafruit MAX31855

Built-in projects that include it. Each page has the full sketch and opens in the editor, already wired.

Kiln and bath probes A K-type thermocouple on a MAX31855 for a kiln past 1000 C and a PT100 on a MAX31865 for the bath beside it, a tenth of a degree at a time.

## Keep going

### Learn

- Arduino MAX31855: K-Type Thermocouple Code
- Arduino MAX6675 Thermocouple: Wiring and Code

### Parts

- Thermocouple converter, MAX31855

### More sensors libraries

- DHT sensor library
- DHT20
- VL53L0X
- Adafruit_VL53L0X
- HX711 Arduino Library
- MPU6050
- Adafruit MPU6050
- BME280
- ClosedCube OPT3001
- GyverDS18
- microDS18B20
- arduino-sht
- Sensirion I2C SHT3x
- SHT4x

Every built-in library · Open the editor

## Try Adafruit MAX31855 without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
