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.

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 CLK 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_MAX31865 library

To begin reading sensor data, you will need to the Adafruit MAX31865 library from the Arduino library manager.

Open up the Arduino library manager:

Search for the Adafruit MAX31865 library and install it

We also have a great tutorial on Arduino library installation at:

Attach PT100 or PT1000 RTD

You'll need to attach an RTD, for this demo we'll be using a 3-wire 1 meter long one but you can adjust the demo if you have a 2 or 4 wire. Check the RTD wiring page for the jumpers and wiring requirements!

Load Demo

Open up File->Examples->Adafruit_MAX31865->max31865 and upload to your Arduino wired up to the sensor. Adjust the max.begin(MAX31865_3WIRE) line if necessary.

Upload to your Arduino and open up the serial console at 115200 baud to see a print out of the sensors data. The MAX31865 doesn't actually return the resistance it measures. Instead it returns the ratio between the resistance measured and the Rref reference resistor.

  • For the PT100 version of the breakout, this is a 430 ohm 0.1% resistor (marking is 4300 !!!)
  • For the PT1000 version of the breakout, this is a 4300 ohm 0.1% resistor (marking is 4301 !!!)

You can use that ratio to calculate the resistance and then determine the temperature

More Accuracy

Our library is efficient and small and uses an algorithm to calculate temperature. While this works very well, it isn't as accurate as it could be. Check out this ITS-90 conforming library from DrHaney that uses a lookup table for better accuracy!

Library Reference

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

// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31865 max = Adafruit_MAX31865(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.
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_MAX31865 max = Adafruit_MAX31865(10);

Once started, you can initialize the sensor with one of the following, depending on what kind of RTD you've got connected!


Reading Resistance

If you want to know the actual resistance (not temperature) you can do that fairly easily. You can read ratio from the MAX31865 with


This will give you the raw 16-bit unsigned value where 0xFFFF is '1.0 ratio'. Chances are you want to convert it to the resistance. We recommend this code:

  Serial.print("RTD value: "); Serial.println(rtd);
  float ratio = rtd;
  ratio /= 32768;
  Serial.print("Ratio = "); Serial.println(ratio,8);
  Serial.print("Resistance = "); Serial.println(RREF*ratio,8);

You'll need to define RREF - in this case its 430.0 for PT100 and 4300.0 for PT1000

Calculating Temperature

Once you have the resistance you can look up in an RTD table or use a calculation to do a best-fit approximation. We use the example from this app note:

It's fast and seems to work very well! We have a one-stop function that does everything for you, just call:

max.temperature(100, RREF)

Where the first argument is the resistance of the RTD at 0°C (for PT100 that's 100) and the second argument is the value of the reference resistor. This function returns the tempreature in °C


The MAX31865 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


Which will return a uint8_t type with bits set for each of 6 different fault types. You can test for each one with this set of code:

  // Check and print any faults
  uint8_t fault = max.readFault();
  if (fault) {
    Serial.print("Fault 0x"); Serial.println(fault, HEX);
    if (fault & MAX31865_FAULT_HIGHTHRESH) {
      Serial.println("RTD High Threshold"); 
    if (fault & MAX31865_FAULT_LOWTHRESH) {
      Serial.println("RTD Low Threshold"); 
    if (fault & MAX31865_FAULT_REFINLOW) {
      Serial.println("REFIN- > 0.85 x Bias"); 
    if (fault & MAX31865_FAULT_REFINHIGH) {
      Serial.println("REFIN- < 0.85 x Bias - FORCE- open"); 
    if (fault & MAX31865_FAULT_RTDINLOW) {
      Serial.println("RTDIN- < 0.85 x Bias - FORCE- open"); 
    if (fault & MAX31865_FAULT_OVUV) {
      Serial.println("Under/Over voltage"); 

In particular, the last four are ones that indicate a hardware failure. The first two are threshold faults, we don't have code for setting those thresholds at this time.

This guide was first published on Nov 15, 2016. It was last updated on Feb 21, 2024.

This page (Arduino Code) was last updated on Nov 15, 2016.

Text editor powered by tinymce.