ESP32 MAX31865 Readings after reconnecting VIN

Hi all,

i have a very strange problem reading the temperature of an PT1000 temperature probe with a MAX31865 amplifier module.
I use the Adafruit library to get the temperature: GitHub - adafruit/Adafruit_MAX31865: Arduino Library for Adafruit MAX31865 RTD Sensor

When the ESP32 boots up I don't get a correct reading.
Only after disconnecting the VIN Pin and reconnecting the VIN Pin, the readings are correct.
After putting the ESP32 in deep sleep and waking it up the readings are incorrect again.

Workflow:
ESP32 boots up -> false reading -> Disconnect VIN -> Connect VIN -> correct reading

Does anyone know what the problem could be. I tried to setup the temperature sensor with a delay of a few seconds but this did not solve the problem.

Thank you very much

Post your wiring between esp and max including power supplies.

Which ESP32?

It is an ESP32 -WROOM-32D (30 Pins)

MAX31865 Pin to ESP32 Pin:
VIN -> 3,3 V
GND -> GND
CLK -> GPIO18
SDO -> GPIO 19
SDI -> GPIO 23
CS -> GPIO 22

The ESP32 board powers the MAX31865 because I read the SPI Bus needs common ground.


The soldering is also correct for 3 wire PT1000. I soldered the 4k3 Ohm resistor as needed.

Code:

#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_MAX31865.h>

// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31865 thermo = Adafruit_MAX31865(22, 23, 19, 18);
// use hardware SPI, just pass in the CS pin
// Adafruit_MAX31865 thermo = Adafruit_MAX31865(10);

// The value of the Rref resistor. Use 430.0 for PT100 and 4300.0 for PT1000
#define RREF 4300.0
// The 'nominal' 0-degrees-C resistance of the sensor
// 100.0 for PT100, 1000.0 for PT1000
#define RNOMINAL 1000.0

void setup()
{
  Serial.begin(115200);
  Serial.println("Adafruit MAX31865 PT100 Sensor Test!");

  thermo.begin(MAX31865_3WIRE); // set to 2WIRE or 4WIRE as necessary
}

void loop()
{
  uint16_t rtd = thermo.readRTD();

  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);
  Serial.print("Temperature = ");
  Serial.println(thermo.temperature(RNOMINAL, RREF));

  // Check and print any faults
  uint8_t fault = thermo.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");
    }
    thermo.clearFault();
  }
  Serial.println();
  delay(1000);
}

Have you tried the hardware SPI

// Use software SPI: CS, DI, DO, CLK
//Adafruit_MAX31865 thermo = Adafruit_MAX31865(10, 11, 12, 13);
// use hardware SPI, just pass in the CS pin
Adafruit_MAX31865 thermo = Adafruit_MAX31865(22);

Yes it was exactly the same.

And it does not report any faults?

This is the output:

RTD value: 0
Ratio = 0.00000000
Resistance = 0.00000000
Temperature = -242.02
Fault 0x40
RTD Low Threshold

After disconnecting VIN and reconnect VIN this is the output:
RTD value: 8320
Ratio = 0.25390625
Resistance = 1091.79687500
Temperature = 23.57

When the ESP32 boots up and i have the VIN disconnected and reconnect the VIN the temperature readings are also correct.
Is it possible that the MAX31865 boots up faster than the ESP32?

Faster or slower it should not give you errors.
It's obviously working or it would not return a value for the Fault.
Not sure what is going on

Vin of the MAX31865 is the input of it's onboard 3.3volt regulator, so should be connected to 5volt (at least 3.5volt). Connect Vin of the MAX to Vin of the ESP.

Use a short/fat USB cable. The ESP can do weird things when it's not getting enough power.
Leo..

I have connected VIN to VIN of the ESP. It is the same result.

Adafruit gives range 3-5V for VIN, so if your board is from them or equal clone, that should not be concern. Are you 100% sure about your soldering quality on selection pads and resistor?

I took a new MAX31865 soldered everything carefully and now it works!
Either the other board is not working correctly or I have messed up some soldering.

Thanks for all the support here!