ESP32 4-Wire PT100/PT1000 High-Accuracy Temperature Measurement with MAX31865
Connect a 4-wire PT100 or PT1000 to ESP32 using a MAX31865 breakout module: wiring, SPI pins, Adafruit library example, and practical accuracy tips.
ESP32 4-Wire PT100/PT1000 High-Accuracy Temperature Measurement with MAX31865
In a previous article, the ESP32 internal ADC reads a PT1000 through a simple divider. That is fine for a basic display, but lead resistance, ADC error, and noise limit how accurate the result can be—especially with PT100.
This tutorial uses a MAX31865 breakout module with 4-wire RTD wiring. The module already includes the chip, reference resistor, and decoupling, so you can focus on SPI wiring and software instead of designing the analog front end. (A discrete ADC such as the ADS1220 is more flexible but harder to design; that path is planned for a follow-up article.)
Under good sensor choice and calibration, about ±0.2°C is a realistic system-level target—not a guarantee from the chip alone.
Why 4-wire RTD?
| Wiring | Idea |
|---|---|
| 2-wire | Easiest; cable resistance adds directly to the reading. |
| 3-wire | Common compromise; compensates one lead. |
| 4-wire | Force current on one pair; sense voltage on another—lead resistance barely affects the sense path. |
For PT100, only ~0.08 Ω of extra resistance is already near 0.2°C error. Long cables make 2-wire unsuitable for precision work. The MAX31865 supports 2-, 3-, and 4-wire modes; this article uses 4-wire.
PT100 and PT1000
| Sensor | R₀ at 0°C |
|---|---|
| PT100 | 100 Ω |
| PT1000 | 1000 Ω |
Match the module and library settings to your probe. Many breakouts ship with a 430 Ω reference and defaults aimed at PT100; PT1000 boards or resistor changes are also common—check the seller’s guide.
Why not the ESP32 ADC alone?
The old approach measures a divider midpoint with the MCU ADC:
Offset, gain, supply drift, noise, and lead resistance all land in one measurement. Moving RTD conversion to a MAX31865 keeps the ESP32 on SPI + math + filtering.
MAX31865 module (recommended)
The IC is an RTD-to-digital converter (15-bit, SPI, ratiometric measurement, optional 50/60 Hz filter). You do not need to build that around a bare chip.
If peripheral design is not the goal, use a ready-made board—for example the Adafruit MAX31865 RTD Sensor Breakout (#3328). Confirm PT100 vs PT1000 and 2/3/4-wire support on the product page.
Chip-level 4-wire RTD connection (reference only; the module implements this for you):

Connect the RTD to the module (4-wire)
On typical breakouts (including Adafruit #3328), the RTD terminals are labeled:
| RTD wire role | Module terminal (common labels) |
|---|---|
| Force + | F+ or FORCE+ |
| Force − | F− or FORCE− |
| Sense + | RTD+ or T+ |
| Sense − | RTD− or T− |
Set the board to 4-wire mode per the vendor instructions (Adafruit uses solder jumpers on the back of the PCB). Use a 4-conductor probe or run four separate conductors from a 2-wire probe head only if you understand the probe wiring—industrial 4-wire RTD probes are the straightforward choice.
Keep RTD wires away from mains cabling and switching supplies when possible.
Connect the module to ESP32 (SPI)
Logic is 3.3 V. Example wiring (VSPI-style pins; change CS if your sketch uses another GPIO):
| ESP32 | MAX31865 module |
|---|---|
| 3V3 | VIN (or 3V3) |
| GND | GND |
| GPIO18 | CLK (SCK) |
| GPIO23 | SDI (MOSI) |
| GPIO19 | SDO (MISO) |
| GPIO5 | CS |
DRDY is optional; polling over SPI is enough for slow temperature loops.
PT100/PT1000 (4-wire)
│
▼
┌───────────────┐
│ MAX31865 │
│ breakout │──── SPI ──── ESP32
└───────────────┘
Software setup
- Install the Adafruit MAX31865 library (Arduino Library Manager:
Adafruit MAX31865, which pulls in Adafruit BusIO). - Select your ESP32 board and port.
- Set
RREFandRNOMINALto match your module reference and probe (Adafruit PT100 example:430.0and100.0).
Example code
#include <SPI.h>
#include <Adafruit_MAX31865.h>
// CS pin — must match your wiring
#define MAX31865_CS 5
// Match your module: PT100 on Adafruit #3328 typically RREF = 430 Ω
#define RREF 430.0f
#define RNOMINAL 100.0f // use 1000.0f for PT1000
Adafruit_MAX31865 max31865 = Adafruit_MAX31865(MAX31865_CS);
void setup() {
Serial.begin(115200);
while (!Serial) {
delay(10);
}
if (!max31865.begin(MAX31865_4WIRE)) {
Serial.println("MAX31865 not found. Check wiring and power.");
while (1) {
delay(1000);
}
}
max31865.clearFault();
max31865.enable50HzFilter(true); // use enable60HzFilter(true) in 60 Hz regions
}
void loop() {
float tempC = max31865.temperature(RNOMINAL, RREF);
float rtdOhms = max31865.readRTD();
Serial.print("Temperature: ");
Serial.print(tempC, 2);
Serial.print(" °C | RTD: ");
Serial.print(rtdOhms, 2);
Serial.println(" Ω");
delay(1000);
}
If readings look noisy, enable the correct line-frequency filter and read at 1–10 Hz—temperature does not need kilohertz sampling. A short moving average in software reduces jitter but does not fix a wrong RNOMINAL or probe class.
Faults
Call max31865.readFault() after suspicious values. clearFault() clears latched faults after you fix wiring or open RTD connections. See the library and datasheet for fault bit meanings.
Accuracy in practice
| Factor | Note |
|---|---|
| Probe grade | Industrial RTD class matters more than extra software averaging. |
| 4-wire | Correct for long leads; wrong jumper mode defeats the purpose. |
| RREF / RNOMINAL | Must match the physical module and sensor. |
| Calibration | Compare against ice water (0°C) or a trusted reference meter; apply offset or two-point correction if needed. |
High ADC resolution is not the same as system accuracy. Treat ±0.2°C as a design goal after probe, wiring, and calibration—not a datasheet promise.
Conclusion
For ESP32 + PT100/PT1000 with better accuracy than the internal ADC, a MAX31865 module in 4-wire mode is the practical route: wire F± and RTD± to the probe, connect SPI to the ESP32, configure 4-wire on the board, and use the Adafruit_MAX31865 library with the correct RREF and RNOMINAL.
Next step: run the example sketch, confirm stable ohms and temperature, then calibrate against a reference if your application needs it.
Related articles
Share this article
Comments
0Please sign in to post a comment.
No comments yet.