PT100 Sensor Not Reading Correctly with MAX31865 - Need Help!

I am back home guys. The new adafruit board arrived and i just tried to run it with the example adafruit liberary code.

Unfortunatly it still doens't work. But now the serial monitor gave error message at least once.. i could not replicate the error code.

i did it like that.. the serial monitor was just this and no fluctations.

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

sm:

Adafruit MAX31865 PT100 Sensor Test!
RTD value: 0
Ratio = 0.00000000
Resistance = 0.00000000
Temperature = -242.02

RTD value: 0
Ratio = 0.00000000
Resistance = 0.00000000
Temperature = -242.02

RTD value: 0
Ratio = 0.00000000
Resistance = 0.00000000
Temperature = -242.02

As I said in post #29
The temperature is out of range but it did not report a fault so you may have a bad connection or bad solder joint somewhere.
Did you do a good job of soldering on the header pins?

Otherwise the module is bad.

1 Like

i just put in an other esp32. still the same.

Not the ESP the MAX31865 module

1 Like

yeah i also switched out the cloned board (pink)to a brand new adafruit board (blue)

that was the old cloned board:

cb5b6340cd3b8480f5664f88c1bcab334000fd27_2_281x500

u mean this?

The new sensor just arrived, but still doens't work. The good thing is that I now get a error code out of the serial monitor.

SM:

RTD value: 0
Ratio = 0.00000000
Resistance = 0.00000000
Temperature = -242.02
Fault 0x6C
RTD Low Threshold
REFIN- > 0.85 x Bias
RTDIN- < 0.85 x Bias - FORCE- open
Under/Over voltage

Could it be that i need pull up or pull down resistors betweeen the sdl and sda pins?

Grettings, Anabol

If I'm not mistaken, that blue wire at the far left should be at the far right.


Different wire colors but you get the idea.
And there may be a thin jumper between 2-4 on the right that you'll have to cut.

You have it wired wrong
Connect the three wires to the three right-most contacts. The ones with the same color are to the right. In your case the blue ones.

Did you get it to worK?

Don't know where you are looking but I see two BLUE wires.

Hi, I am having the same issue with the RTD.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_MAX31865.h>
#include <PID_v1.h>

// Pin Definitions
#define RELAY_PIN 7

// RTD Sensor (PT100) - MAX31865 Setup
#define MAX31865_CS_PIN 10
Adafruit_MAX31865 thermo = Adafruit_MAX31865(MAX31865_CS_PIN, 11, 12, 13); // CS, DI, DO, CLK

// PID Variables
double setPoint = 60.0;
double inputTemp, outputTemp;
double Kp = 2.0, Ki = 0.0, Kd = 0.0;
PID myPID(&inputTemp, &outputTemp, &setPoint, Kp, Ki, Kd, DIRECT);

// LCD Display Setup (I2C)
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
Serial.begin(9600);

pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, LOW);

thermo.begin(MAX31865_3WIRE);

myPID.SetMode(AUTOMATIC);
myPID.SetOutputLimits(0, 255);

lcd.init();
lcd.backlight();
displayMessage("PID Control", "Initializing...");
delay(2000);
lcd.clear();
}

void loop() {
uint16_t rtd = thermo.readRTD();
Serial.print("Raw RTD: ");  // Add this line
Serial.println(rtd);        // Add this line
inputTemp = thermo.temperature(rtd, MAX31865_3WIRE);

printSerialData(inputTemp); // Just print the temperature

myPID.Compute();
controlHeatingElement(outputTemp);

displayTemperature();

delay(1000);
}

void printSerialData(double temp) {
Serial.print("Temperature: ");
Serial.println(temp);
Serial.print("PID Output: ");
Serial.println(outputTemp);
}

void controlHeatingElement(double output) {
analogWrite(RELAY_PIN, output); // PWM Control
}

void displayTemperature() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Set: ");
lcd.print(setPoint);
lcd.print("C");

lcd.setCursor(0, 1);
lcd.print("Temp: ");
lcd.print(inputTemp);
lcd.print("C");
}

void displayMessage(const char *line1, const char *line2) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(line1);
lcd.setCursor(0, 1);
lcd.print(line2);
}

These are the results in my serial monitor.

Temperature: -242.01
PID Output: 255.00
Raw RTD: 7778

#include "Adafruit_MAX31865.h"

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

#define RREF 430.0
#define RNOMINAL 100.0

void setup() {
  Serial.begin(9600);
  thermo.begin(MAX31865_3WIRE);  // 2WIRE, 3WIRE, 4WIRE 
}  

void loop() {
  uint8_t fault = thermo.readFault();
  if (fault) {
    Serial.print("Fault 0x");
    Serial.println(fault, HEX);
    thermo.clearFault();
  } else {
    float temp = thermo.temperature(RNOMINAL, RREF);
    Serial.print("Temp:");
    Serial.println(temp);
  }
  

}

When I plug in the code above, my results show ~5.5C inside an ice bath.

image

uint16_t rtd = thermo.readRTD();
Serial.print("Raw RTD: ");  // Add this line
Serial.println(rtd);        // Add this line
inputTemp = thermo.temperature(rtd, MAX31865_3WIRE);

Seems like the OP's code also has the above code. Could that be causing the issue he is describing that I am also experiencing?

@anabolicsurgeon not sure if you need the help, but i was able to figure out how to make it work. here is the code that I used to make it work.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_MAX31865.h>
#include <PID_v1.h>

// Pin Definitions
#define RELAY_PIN 7

// RTD Sensor (PT100) - MAX31865 Setup
Adafruit_MAX31865 thermo = Adafruit_MAX31865(10, 11, 12, 13);

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

// PID Variables
double setPoint = 60.0;
double inputTemp, outputTemp;
double Kp = 5.0, Ki = 0.0, Kd = 0.0;
PID myPID(&inputTemp, &outputTemp, &setPoint, Kp, Ki, Kd, DIRECT);

// LCD Display Setup (I2C)
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  Serial.begin(9600);

  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW);

  thermo.begin(MAX31865_3WIRE);  // Initialize the sensor for 3-wire PT100

  myPID.SetMode(AUTOMATIC);
  myPID.SetOutputLimits(0, 255);

  lcd.init();
  lcd.backlight();
  displayMessage("PID Control", "Initializing...");
  delay(2000);
  lcd.clear();
}

void loop() {
  // Read the raw RTD resistance
  uint16_t rtd = thermo.readRTD();

  // Debugging the raw RTD resistance and ratio calculation
  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);

  // Now calculate the temperature from the RTD resistance
  inputTemp = thermo.temperature(RNOMINAL, RREF); // PT100 sensor (nominal resistance: 100), Reference resistor: 430

  Serial.print("Temperature = "); Serial.println(inputTemp);

  // 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();
  }

  // Compute PID output based on the current temperature
  myPID.Compute();

  // Print PID data to Serial Monitor
  printSerialData(inputTemp);

  // Control Heating Element via Relay (PWM control)
  controlHeatingElement(outputTemp);

  // Display current temperature on the LCD
  displayTemperature();

  // Wait for a second
  delay(1000);
}

// Function definitions

void displayMessage(const char* line1, const char* line2) {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(line1);
  lcd.setCursor(0, 1);
  lcd.print(line2);
}

void printSerialData(double temp) {
  Serial.print("Temperature: ");
  Serial.println(temp);
  Serial.print("PID Output: ");
  Serial.println(outputTemp);
}

void controlHeatingElement(double output) {
  analogWrite(RELAY_PIN, output); // PWM Control
}

void displayTemperature() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Set: ");
  lcd.print(setPoint);
  lcd.print("C");

  lcd.setCursor(0, 1);
  lcd.print("Temp: ");
  lcd.print(inputTemp);
  lcd.print("C");
}

Hi,
Can I suggest you get that AC Mains to DC power supply AWAY from the input module.

Bad placement, AC-DC converter is a switching device, emitting EMR, your 31865 is a low level input signal device.
Not a good combination so close together.

Also place a 0.1uF capacitor across a RED/BLUE pair of terminals on the input to the 31865.

Tom.... :smiley: :+1: :coffee: :australia: