BentuinoMAX31865 — A High-Quality MAX31865 Driver for Arduino & PlatformIO

Share

Background

The thermal solar controller on my roof started as an ESPHome project. ESPHome has a built-in MAX31865 component that gets you up and running in a few lines of YAML — fast to prototype, easy to integrate with Home Assistant. But once the system was reading real temperatures, the measurements were rather noisy.

That prompted a closer read of the MAX31865 datasheet and the ADI application notes. A key issue is that the ESPHome component leaves VBIAS on continuously. VBIAS powers the sense excitation circuit, and keeping it on between readings causes the reference resistor to self-heat — elevating its resistance slightly and biasing every measurement.

I moved the project off ESPHome and worked with Claude Code to write a custom Arduino/PlatformIO driver — going through the datasheet, ADI application notes, and IEC 60751 together to get the conversion and VBIAS sequencing right. The result is BentuinoMAX31865, now published on GitHub.

What it does

BentuinoMAX31865 is a high-quality driver for the Maxim MAX31865 RTD-to-digital converter. It handles the full one-shot measurement lifecycle — VBIAS management, fault detection, and IEC 60751 temperature conversion — with shared SPI bus safety throughout.

#include BentuinoMAX31865.h

BentuinoMAX31865 rtd(CS_PIN, SPI);

rtd.begin(4300.0f,
          BentuinoMAX31865::RtdType::PT1000,
          BentuinoMAX31865::WireMode::W2,
          BentuinoMAX31865::FilterNotch::Hz60);

float tempC;
uint8_t fault;
if (rtd.readTemperatureC(&tempC, &fault)) {
    // use tempC
} else {
    // fault & BentuinoMAX31865::kFaultRtdinLow -- open wire
}

How it compares

  • Temperature conversion — IEC 60751 conversion: closed-form quadratic above 0 °C, Analog Devices AN709 inverse polynomial below — accurate to < 0.001 °C, below the sensor's noise floor.
    • Adafruit: Same AN709 polynomial below 0 °C — equivalent accuracy.
    • ESPHome: Same conversion math — equivalent accuracy.
  • VBIAS — One-shot: on only during each read, off immediately after — no idle self-heating.
    • Adafruit: Continuous by default in auto-convert mode; one-shot available but lifecycle left to caller.
    • ESPHome: Continuous — always on, contributing to reference resistor self-heating and measurement noise.
  • SPI bus sharing — Every transfer wrapped in beginTransaction / endTransaction; safe on a shared bus with a display, SD card, or any other SPI device.
    • Adafruit: Also shared-bus safe — its BusIO layer wraps each transfer in a transaction, and adds a software bit-bang SPI option.
  • Fault handling — Enforces spec §5.1 ordering, runs the full hardware detection cycle, detects stuck MISO (0x0000 / 0xFFFE), and provides a startup self-check via checkCommunication().
    • Adafruit: Reads the fault register; no hardware detection cycle or stuck-SPI detection.
    • ESPHome: Reads the fault register only.
  • Calibration — setReferenceScale() to trim reference resistor tolerance, setLeadResistanceOhms() for 2-wire lead compensation, and a separate readResistanceOhms() API layer.
    • Adafruit: No calibration hooks — R_ref is fixed at construction, no lead compensation.
  • PT1000 — First-class support: RtdType::PT1000 sets R0 = 1000 Ω directly in the CVD calculation.
    • Adafruit: Same R0 handling via a per-call parameter and identical conversion math; the difference is ergonomic (typed enum vs. parameter).
  • Setup & integration — C++ / PlatformIO; full control over the measurement loop, WiFi stack, and MQTT publishing.
    • ESPHome: YAML config only — no code required, instant Home Assistant auto-discovery. The better choice if HA integration is the sole goal.

When to use each

BentuinoMAX31865 you need a shared SPI bus with other peripherals, minimal idle power draw, calibration trimming, or production-grade fault diagnostics.

Get it

The library is MIT-licensed and available on GitHub, including the full driver spec, device reference notes, and a self-contained PlatformIO test firmware for the M5Stack Core2. The driver and documentation were developed with AI assistance using Claude Code.

github.com/knkaiser/BentuinoMAX31865