0% found this document useful (0 votes)
36 views16 pages

MAX31865 RTD Sensor with Arduino Guide

How to connect PT100 sensor with Arduino over MAX31865

Uploaded by

nurajmaduranga
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views16 pages

MAX31865 RTD Sensor with Arduino Guide

How to connect PT100 sensor with Arduino over MAX31865

Uploaded by

nurajmaduranga
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MAX31865 RTD Sensor And Arduino

Puneeth Kumar

In this tutorial you will learn how to use RTD sensors with the MAX31865 and Arduino. RTD sensors are highly accurate, robust temperature sensors
and the MAX31865 is a resistance-to-digital
converter that makes it easy to connect RTD sensors with a microcontroller such as an Arduino.

In the following sections you will learn about different types of RTD sensors, how they work and how to connect them to a MAX31865 board. We will
also look at the function of the MAX31865, and how read temperature data using the Adafruit_MAX31865 library.

Let’s get started with the required parts.

Overview

Required Parts
MAX31865
RTD Pt100 Sensor
Arduino Uno
Dupont Wire Set
USB Cable for Arduino UNO
RTD Sensor
Temperature response of RTDs
Callendar Van Dusen equation
Wiring configurations of RTDs
Technical Specification of the Pt100 RTD
Test your Pt100 RTD
MAX31865 Board
Breakout board for MAX31865
Connecting the RTD Sensor to the MAX31865
3 Wire RTD
Cutting trace
Connecting the 3 wires
4 Wire RTD
2 Wire RTD
Connecting the MAX31865 to Arduino
Reading RTD temperature data from the MAX31865
Code Example
Serial plotter and monitor output
Debugging
RTD incorrectly connected
MAX31865 board incorrectly configured
RTD Thresholds exceeded
Conclusions
Links

Required Parts
I used an Arduino Uno for this project but any other Arduino board, or an ESP8266/ESP32 board will also work. Note that I selected the common
Pt100 Sensor and the corresponding MAX31865 board. If you prefer a Pt1000 you should buy a matching board, otherwise you will have to change the
reference resistor on the MAX31865 board. You can find more details in the later sections.
Makerguides is a participant in affiliate advertising programs designed to provide a means for sites to earn advertising fees by linking to Amazon,
AliExpress, Elecrow, and other sites. As an Affiliate we may earn from qualifying purchases.

RTD stands for “Resistance Temperature Detector”. An RTD sensor is essentially a temperature sensitive resistor that changes resistance when
the temperature changes.

RTD sensors have high accuracy, stability, and repeatability. They provide a largely linear output over a wide temperature range and are normally
housed in a protective cable, which makes them very robust. However, they are more expensive than thermocouples and thermistors, and they have
slower response times.

The most common RTDs are wire wound, platinum RTDs. They consist of a platinum wire that is wound around a ceramic core. The length of this
platinum wire is chosen to achieve a specified resistance at 0°C. This is called the R0 resistance. For the Pt100 Sensor the R0 resistance is 100 Ω and
for the Pt1000 the resistance is 1000Ω, for instance. And Pt refers to the fact that the sensor is made from platinum.

Temperature response of RTDs


RTDs are very accurate but not completely linear in their temperature response. The following diagram shows the change in resistance of a Pt100
sensor depending on temperature compared to a completely linear response.

Pt100 RTD resistance vs. temperature (source)

Callendar Van Dusen equation


You can see there is a deviation from the ideal line at higher temperatures. This deviation or curvature can be described by the so called “Callendar Van
Dusen” equation:

Callendar Van Dusen equation (source)

For accurate temperature readings at higher temperatures you would have to implement this equation. Luckily the Adafruit_MAX31865 library has
this compensation already built in, and we don’t have to worry about it.

Finally, there are many other RTD types, that use different materials with different resistance values, but in this tutorial we are focusing on the
common Pt100 RTD. For more information on other types of RTDs have a look at this article: RTDs – the key to accurate industrial temperature
measurements.

Wiring configurations of RTDs


RTDs come in 2-wire, 3-wire, or 4-wire configurations, with the 3-wire configuration being the most common one.
RTD wire configurations

Two wires are used to connect to the internal temperature sensitive resistor element of the RTD. However, the wires themselves have resistance as
well. To be able to measure their resistance and to compensate for it, one or two additional wires are connected in the 3- and 4-wire RTDs as shown
above.

Two-wire RTDs are typically chosen for applications where accuracy is not critical and the wires are short. They are easy to use but are less accurate
since there is no compensation for the resistance of the wires possible.

Three-wire RTDs are the most common configuration that compensates for the resistance added by the wires, allowing for better accuracy and
longer wires. With this configuration, the controller makes two measurements. The first measures the total resistance of the sensor and the connecting
wires. The second the resistance of the compensation loop. By subtracting the compensation loop resistance from the total resistance, a net resistance
can be calculated.

Compensation loop and total resistance of RTD

Four-wire RTDs essentially add a second compensation loop for even better compensation of wire resistance and higher accuracy. This configuration
is used for precision measurements in laboratories and other applications where top accuracy is needed.

In this tutorial we are specifically going to use the 3-wire Pt100 RTD and its specifications are listed in the next section.

Technical Specification of the Pt100 RTD


The Pt100 is a 3-wire RTD with a nominal resistance of 100Ω at 0°C. The resistive wire is made of Platinum and the housing of the probe and the cable
wrapping are made of stainless steel. Sensor and cable are water tight. The sensor has a temperature range from -50 to 200℃ with an accuracy of
±0.15 °C.
Pt100 3-wire RTD

Test your Pt100 RTD


You can test the correct function of your Pt100 RTD with a multimeter. First identify the two wires that have a very low resistance of around 2Ω. The
exact value will depend on the length of the wires. Typically these two wires have the same color coding – blue in my case – but that is not always so.

Resistance values of Pt100 RTD

Then measure the resistance between one of the blue wires and the red wire. At room temperature it should be around 110Ω. If you then place the
sensor into an ice bath (0°C) the resistance should drop to 100Ω. For the Pt1000 that resistance at 0°C would be 1000Ω.

In the next section we are going to connect the Pt100 RTD to the MAX31865 Board.

MAX31865 Board
The MAX31865 is a precision analog front-end IC for platinum RTD temperature sensors. It works by measuring the resistance of the RTD sensor and
converting it into a digital value using a built-in analog-to-digital converter (ADC). Below the block diagram of the internals of the MAX31865 IC.
Block diagram of MAX31865 IC (source)

You can see the inputs for the RTD on the left (RTDIN+, RTDIN-, FORCE), the 15-bit ADC in the center and the SPI interface (SCLK, SDO, SDO, CS)
on the right. The RTD sensor itself will be connected to the RTDIN+, RTDIN- inputs, while the FORCE pins are used to measure the wire resistance.
The following table describes the all the pins and their functions.

Pin Description of MAX31865 IC (source)

The MAX31865 can handle PT100 or PT1000 sensors in 2-wire, 3-wire, or 4-wire configurations. Due to the 15-bit ADC it is very accurate with a
resolution of 0.03125°C and a fast conversion time of 21ms. Furthermore, it has a built-in fault reporting function for errors such as Open RTD
Element, RTD Shorted,
Out-of-Range Voltage, or Short Across RTD Element. For more information have a look at the datasheet.

Breakout board for MAX31865


Typically you don’t use the MAX31865 IC directly but in the shape of a breakout board. There are different versions but I am going to focus on the one
listed in the Required Parts. The picture below shows the top and bottom of the MAX31865 breakout board.

MAX31865 breakout board

You can see the inputs for the SPI interface and the RTD sensor marked. The board runs on 5V or 3.3V and therefore works nicely with Arduino or
ESP32 microcontrollers.

You have to watch out when buying a MAX31865 breakout board. It should match your RTD sensor. The MAX31865 breakout boards differ in the Rref
resistor that is pre-soldered on the board. If you have a Pt100 RTD you want a board with a Rref = 430Ω (labelled as 4300). But for a Pt1000 the Rref
should be 4300Ω (lablled as 4301):

MAX31865 breakout boards with different Rref resistors

Though, you can replace the Rref resistor if you need to, because otherwise the boards are identical.

Connecting the RTD Sensor to the MAX31865


When connecting the RTD Sensor to the MAX31865 it is easy to make mistakes and you will get fault message from MAX31865 if you do it wrong.
Please read the following sections carefully!

We start with the description of the wiring and board setup for the 3-wire RTD, since this is the most common configuration.

3 Wire RTD
Before you connect the RTD wires to the board you have to prepare the board for the 3-wire configuration. Specifically, you need to do the following
three steps:

1. Solder together the two pads labelled “2/3 Wire“


2. Solder together the two right-most pads of the section labelled “24 3“
3. Cut the thin trace between the two left-most pads of the section labelled “24 3“
The picture below shows the relevant locations on the breakout board (marked yellow)

Preparing MAX31865 board for 3-wire RTD

Cutting trace

Note that the trace to cut is very thin and difficult to see. You will need a small, sharp knife to cut it. Watch out not to cut any other trace accidentally.
The following picture shows a close-up of the trace that needs to be cut.

Close-up of trace to be cut

For some boards this small trace is even covered by color and almost invisible. After cutting the trace verify with a multimeter that there is no
connection between the left and right pad anymore. I even took a microscope picture (after soldering) to make sure that I got a nice cut between the
pads.
“24 3” pad soldered and cut

Below is another close up of the board that shows how the three sections with pads should look like after soldering and cutting.

Close up of MAX31865 board configured for 3-wire RTD

Connecting the 3 wires

Finally we need to connect the three wires of the Pt100 RTD. You will notice that the end contacts it comes with are actually do not fit in the terminals.
You will need to use pliers and fold them to make them small enough to fit. The picture below shows the contacts before and after.
Folding the end contacts of the Pt100 RTD

Now you can insert them into the terminals. The two wires with the same color (low resistance loop) go into the right terminal (the terminal close to
the “2 Wire” pad). And the wire with the other color goes into the left terminal. See picture below.

Connecting 3-wire RTD Sensor to MAX31865 board

Which port of the left terminal block you are using for the red wire doesn’t matter. The solder blob on the “2/3 Wire” pad shortcuts those two ports.

If you look at the datasheet for the MAX31865, you will see that we are making the following connections between the MAX31865 and the 3-wire RTD:

3-wire RTD connection with MAX31865

4 Wire RTD
For the 4-wire configuration you don’t have to do anything. Just leave the board as it is, without soldering any pads or cutting any traces.
MAX31865 board for 4-wire RTD

With a four wire RTD the wires with same color typically go into the same terminal (left or right). The order of the wires within the terminal doesn’t
matter.

Connecting 4-wire RTD Sensor to MAX31865 board (source)

To be sure, use a multimeter and confirm that the wires that go into the same terminal have low resistance (2Ω).

2 Wire RTD
For the 2-wire configuration you have to solder the “2/3 Wire” pad and the “2 Wire” pad but you must not cut the thin trace of the “24 3” pad section.
Preparing MAX31865 board for 2-wire RTD

Connecting the 2-wire RTD is very simple. Each of the two cables has to to go into a different terminal block (left or right). The order of the cables does
not matter.

Connecting 2-wire RTD Sensor to MAX31865 board

Connecting the MAX31865 to Arduino


Once you have prepared the MAX31865 board and connected the RTD sensor we are ready to connect the MAX31865 to the Arduino. The wiring
diagram below shows the connections. Note that the RDY output of the MAX31865 board is not used.
Connecting MAX31865 to Arduino

The following table also lists the connection you need to make between the Arduino and the MAX31865 board.

Arduino MAX31865
10 CS
11 SDI
12 SDO
13 CLK
– RDY
5V VIN
GND GND

Reading RTD temperature data from the MAX31865


After everything is connected we can write some code. If you haven’t already installed the Adafruit_MAX31865 library, now is the time to do it. Go to
Tools > Manage Libraries ... and open the LIBRARY MANAGER. Search for “Adafruit_MAX31865” and press install. Once done, it should look like
this.

Install Adafruit_MAX31865 via LIBRARY MANAGER

Code Example
With that out of the way, below is a minimal example of how to read temperature data from the MAX31865. Have a quick look at the code first and
then we discuss the details.
#include "Adafruit_MAX31865.h"

Adafruit_MAX31865 thermo = Adafruit_MAX31865(10, 11, 12, 13);

#define RREF 430.0


#define RNOMINAL 100.0

void setup() {
[Link](9600);
[Link](MAX31865_3WIRE); // 2WIRE, 3WIRE, 4WIRE
}

void loop() {
uint8_t fault = [Link]();
if (fault) {
[Link]("Fault 0x");
[Link](fault, HEX);
[Link]();
} else {
float temp = [Link](RNOMINAL, RREF);
[Link]("Temp:");
[Link](temp);
}
delay(1000);
}

The code starts by including the Adafruit_MAX31865 library and creating the thermometer object thermo. When creating the object we have to provide the
Arduino pins used to communicate with the MAX31865 via SPI. In our case these are CS=10, DI=11, DO=12, CLK=13.
#include "Adafruit_MAX31865.h"

Adafruit_MAX31865 thermo = Adafruit_MAX31865(10, 11, 12, 13);

Next we define the constants for the RTD sensor. In the case of the Pt100 RTD we have reference resistance of 430Ω and a nominal resistance a 0
degrees of 100Ω.
#define RREF 430.0
#define RNOMINAL 100.0

If you use a Pt1000 RTD or different RTD you would use RREF=4300.0 and RNOMINAL=1000.0.

In the setup function, we initiate the serial communication and also the communication with the MAX31865. Note that we are specifying a 3-wire RTD
(MAX31865_3WIRE). Change this parameter if you have a 2-wire (MAX31865_2WIRE) or a 4-wire (MAX31865_4WIRE) RTD connected.
void setup() {
[Link](9600);
[Link](MAX31865_3WIRE);
}

Finally, in the loop function we first check for faulty readings. If we receive a fault message, we print “Fault” to the Serial Monitor and clear the fault.
Otherwise we read the temperature from the MAX31865 and print it.
void loop() {
if ([Link]()) {
[Link]("Fault!");
[Link]();
} else {
float temp = [Link](RNOMINAL, RREF);
[Link]("Temp:");
[Link](temp);
}
delay(1000);
}

And that’s it. Now you can measure temperature using an RTD sensor and the MAX31865!

Serial plotter and monitor output


On your Serial Monitor you should now see printed out every second the ambient temperature in grad Celsius.

Serial Monitor showing temperature measurements

And you can the follow the change in temperature by opening the Serial Plotter. Warm up the sensor a bit by holding it in your hand, or cool it down by
blowing on it.
Serial Monitor showing temperature curve

Debugging
As you have seen, connecting the RTD wires and preparing the MAX31865 board correctly can be a bit tricky and if anything is wrong, you will not be
able get any useful temperature readings. Luckily the MAX31865 is able to detect and report certain faults, which can be helpful in debugging.

The Adafruit_MAX31865 library comes with an example program that prints out the fault codes returned from the MAX31865. Below is a slightly
modified version of that example code for the 3-wire Pt100 RTD.
#include "Adafruit_MAX31865.h"

Adafruit_MAX31865 thermo = Adafruit_MAX31865(10, 11, 12, 13);

#define RREF 430.0


#define RNOMINAL 100.0

void setup() {
[Link](9600);
[Link](MAX31865_3WIRE);
}

void loop() {
uint16_t rtd = [Link]();
float ratio = rtd / 32768.0;

[Link]("RTD value: ");


[Link](rtd);
[Link]("Ratio = ");
[Link](ratio, 8);
[Link]("Resistance = ");
[Link](RREF * ratio, 8);
[Link]("Temperature = ");
[Link]([Link](RNOMINAL, RREF));

uint8_t fault = [Link]();


if (fault) {
[Link]("Fault 0x");
[Link](fault, HEX);
if (fault & MAX31865_FAULT_HIGHTHRESH) {
[Link]("RTD High Threshold");
}
if (fault & MAX31865_FAULT_LOWTHRESH) {
[Link]("RTD Low Threshold");
}
if (fault & MAX31865_FAULT_REFINLOW) {
[Link]("REFIN- > 0.85 x Bias");
}
if (fault & MAX31865_FAULT_REFINHIGH) {
[Link]("REFIN- < 0.85 x Bias - FORCE- open");
}
if (fault & MAX31865_FAULT_RTDINLOW) {
[Link]("RTDIN- < 0.85 x Bias - FORCE- open");
}
if (fault & MAX31865_FAULT_OVUV) {
[Link]("Under/Over voltage");
}
[Link]();
}
[Link]();
delay(3000);
}

If you run this code, and everything is correctly wired and configured you should see something like the following text on your Serial Monitor.
RTD value: 8300
Ratio = 0.25329589
Resistance = 108.91723632
Temperature = 22.89

Specifically, we see that the RTD returned a non-zero reading (8300) that could be converted into a reasonable resistance value (108.9Ω) for a Pt100
sensor. And we get a correct reading of the current temperature in grad Celsius (22.89).

RTD incorrectly connected


If I pull the red cable out of the terminal and therefore disrupt the connection of the Pt100 with the MAX31865, I get the following error message:
RTD value: 32767
Ratio = 0.99996948
Resistance = 429.98687744
Temperature = 988.79
Fault 0xA8
RTD High Threshold
REFIN- > 0.85 x Bias
RTDIN- < 0.85 x Bias - FORCE- open

MAX31865 board incorrectly configured


On the other hand, if you see an error message similar to this, with an RTD value of zero and an negative temperature, it usually indicates that the pads
are not correctly soldered or that the trace was not cut.
RTD value: 0
Ratio = 0.00000000
Resistance = 0.00000000
Temperature = -242.02
Fault 0x68
RTD Low Threshold
REFIN- > 0.85 x Bias
RTDIN- < 0.85 x Bias - FORCE- open

RTD Thresholds exceeded


Finally, the Adafruit_MAX31865 library has a function setThresholds(lower,upper) that allows you to set thresholds on the minimal and maximal RTD
values. If those limits are exceeded the MAX31865 will report a fault like this (despite everything wired correctly).
RTD value: 8292
Ratio = 0.25305175
Resistance = 108.81225585
Temperature = 22.62
Fault 0x80
RTD High Threshold

For more detailed information on the fault conditions the MAX31865 can detect, have a look at the Datasheet of the MAX31865.

Conclusions
RTD Sensors are accurate and robust temperature sensors that come in different wire configuration 2-, 3, 4-wire). These different wire configurations
require specific changes to the MAX31865 board, which makes a successful connection of RTD, MAX31865 and Arduino a bit tricky.

If your MAX31865 reports zero resistance, large negative temperatures or other faults, it is usually due to a misconfigured board or connection.

I hope this tutorial helps you to avoid the common pitfalls with RTDs and the MAX31865 board. If you have any questions feel free to leave them in the
comment section.

If you are interested in other temperature sensors have a look at the following tutorial:

DHT11/DHT22 Sensor with Arduino Tutorial (2 Examples)


Interfacing Arduino To An NTC Sensor
DS18B20 Temperature Sensor Arduino Tutorial (4 Examples)
LM35 Temperature Sensor Arduino Tutorial (3 Examples)
TMP36 Temperature Sensor Arduino Tutorial (2 Examples)
AM2320 I2C Temperature and Humidity Sensor Arduino …

And now, have fun with your temperature measurements ; )

Links
Here some links I found useful when writing this tutorial.

Understanding RTDs
What Is RTD Sensor And How Does It Work?
Getting Started with High Precision Temperature Sensing using a MAX31865 and PT1000
RTDs – the key to accurate industrial temperature measurements
Adafruit MAX31865 RTD PT100 or PT1000 Amplifier
Adafruit_MAX31865 libary
MAX31865 Datasheet

I am Puneeth. I love tinkering with open-source projects, Arduino, ESP32, Pi and more. I have worked with many different Arduino boards and
currently I am exploring, Arduino powered LoRa, Power line communication and IoT.

Common questions

Powered by AI

The code includes functions to detect and handle faults such as RTD High Threshold and Under/Over voltage. These capabilities allow the system to clear faults and retry operations, enhancing data reliability and offering clear diagnostics for troubleshooting. This proactive fault handling identifies issues before they cause larger errors in measurement data .

RTD sensors offer high accuracy, stability, and repeatability, and they provide a largely linear output over a wide temperature range. They are robust because they are typically housed in protective cables. However, they are more expensive than thermocouples and thermistors and have slower response times .

RREF (reference resistor value) and RNOMINAL (nominal resistance at 0°C) are crucial for accurate temperature measurement. For a Pt100, RREF = 430Ω and RNOMINAL = 100Ω. For a Pt1000, these values are typically 4300Ω and 1000Ω, respectively. Misconfiguring these parameters affects measurement accuracy by not compensating correctly for the sensor characteristics .

The MAX31865 is a precision analog front-end IC that measures the resistance of RTD sensors, converting this into a digital value using an ADC. Its fault reporting feature can detect errors such as Open RTD Element and RTD Shorted, enhancing system reliability by enabling the identification and correction of errors .

Connect CS, DI, DO, and CLK pins of the MAX31865 to respective pins 10, 11, 12, and 13 on the Arduino and power it through VIN and GND. Common pitfalls include mismatched boards for sensor type, incorrect soldering or pad configurations, and wrong pin connections, leading to zero readings or fault conditions such as high thresholds .

The Callendar Van Dusen equation accounts for the deviation from linearity in resistance-temperature characteristics of RTDs at higher temperatures. By implementing this equation, accurate temperature readings are ensured, as it compensates for non-linearity. The Adafruit_MAX31865 library already includes this compensation, simplifying its implementation .

The Adafruit_MAX31865 library simplifies RTD integration by handling protocol communications, incorporating the Callendar Van Dusen compensation, and managing fault reporting. This reduces the complexity of coding needed for temperature measurement, making it accessible for engineers with limited embedded programming experience .

To test a Pt100 RTD, first identify the wires with low resistance (approximately 2Ω). Measure the resistance between any of these wires and another wire; it should be around 110Ω at room temperature. In an ice bath (0°C), the resistance should ideally drop to 100Ω .

2-wire RTDs are simplest but least accurate as they don't compensate for wire resistance, suitable for non-critical applications with short wires. 3-wire RTDs, the most common, achieve better accuracy by compensating for wire resistance through an extra wire, allowing for longer cable runs. 4-wire RTDs are used for precision measurements as they include additional compensation for even higher accuracy .

Correct color coding minimizes wiring errors that disrupt measurements. Troubleshoot connectivity by checking resistance with a multimeter; incorrect wire placement leads to unexpected readings or error codes. Confirming correct terminal insertion and ensuring low resistance in connections are key first steps in rectifying issues .

You might also like