Problems in reading Temperature using MAX31865


I'm doing an experiment in which I'm going to compare the readings in temperature of a LM35 sensor and and RTD Pt100 (2-wire), using the MAX31865. I connected the circuit as the image shows, using the analog pin A0 for the lm35, and the max31865 pins were connected as follows:

Vin -> 5V
GND -> GND
SCK -> D13
MISO -> D12
MOSI -> D11
CS -> D10

I'm using the following code to read the temperatures:

// Codigo para leitura do LM35 e PT100 com referencia interna de 1.1V
#include <Adafruit_MAX31865.h>

// Definicao dos pinos
#define LM35_PIN A0  // Pino do sensor LM35
#define MAX_CS 10     // Chip Select do MAX31865

// Inicializacao do objeto para leitura do PT100
Adafruit_MAX31865 max31865 = Adafruit_MAX31865(MAX_CS);

void setup() {
    Serial.begin(9600);  // Inicializa a comunicacao serial
    analogReference(INTERNAL);  // Define a referencia de tensao interna para 1.1V
    max31865.begin(MAX31865_2WIRE);  // Configura o MAX31865 para modo de 2 fios

    if (!max31865.begin(MAX31865_2WIRE)) {
      Serial.println("Erro na inicialização do MAX31865!");
      while (1); // Para o código se houver erro
}

}

void loop() {
    // Leitura do LM35
    int leituraLM35 = analogRead(LM35_PIN);
    float temperaturaLM35 = (leituraLM35 * 1.1 / 1023.0) * 100.0;  // Conversao para temperatura

    // Leitura do PT100
    float temperaturaPT100 = max31865.temperature(100.0, 430.0);

    uint16_t rtd = max31865.readRTD();
    Serial.print("RTD Raw: "); Serial.println(rtd);
    Serial.print("Status: "); Serial.println(max31865.readFault());

    if (max31865.readFault()) {
      Serial.println("Erro no RTD! Verifique conexões.");
      max31865.clearFault();  // Limpa o erro
}


    // Exibe os valores no monitor serial
    Serial.print("LM35: ");
    Serial.print(temperaturaLM35);
    Serial.print(" °C | PT100: ");
    Serial.print(temperaturaPT100);
    Serial.println(" °C");

    delay(1000);
}

When I run the code, the lm35 readings are great, but the RTD show only 988 degrees, or -242 degrees, the same 2 values in every reading. The "Raw" status show as "Zero" in the serial monitor.

Is there something wrong with the code? I tried to fix it in various ways, but the problem persists.
Also, what would be the correct way to connect the RTD in the max31865? I read that I should connect both wires in the RTD+ and RTD- of the module, and then make a short circuit between F- and RTD-. Is there something wrong with that project?

Thanks and advance for all the help!

I moved your topic to an appropriate forum category @konakona3

In the future, when creating a topic please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Are you using the Adafruit MAX31865 RTD PT100 board?

Did you short the jumpers for 2-Wire RTD?


I'm using this ma31865 module. I used previously a MAX31856 module, bought at the same store, and it worked with the adafruit library, so I would assume it works with this MAX31865 adafruit library too.

I didn't try to connect the wires like that. I will try it again and return if it works. Thanks for the help!

It worked! I was missing the short-circuit between the RTD+ and F+. Sorry for trouble, and thanks a lot for the help!

Could I also ask another question? If I also use a 3-wire RTD, where should I connect each wire? Also, is there any way to guarantee that the 2-wire reading is the most precise I could get? I getting around 2 Celsius Degrees difference between the LM35 and the RTD Pt100. Is it normal, as the LM35 would be much more precise anyway, or could I add something to filter the RTD reading?

This website explains how to use 2-3-4 wire RTD.
Overview | Adafruit MAX31865 RTD PT100 or PT1000 Amplifier | Adafruit Learning System

Also, is there any way to guarantee that the 2-wire reading is the most precise I could get?

If you want the most accurate results, then you need to calibrate both temperature sensors. Take measure ments at 0 and 100 degrees C and see how far off the measurements are.

Thank you so much for the help! I will calibrate the sensors, and also study more using the link you gave me!