Page 1 of 1

[maple mini] Adafruit_MAX31865 library : The correct value is not displayed.

Posted: Wed Nov 20, 2024 8:38 am
by myksj1105
[maple mini] Adafruit_MAX31865 library : The correct value is not displayed.


1. Adafruit_MAX31865 library : https://www.adafruit.com/product/3328

2. PT-100 : 2wire

3. CODE :

Code: Select all

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

// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31865 thermo = Adafruit_MAX31865(PA4, PA7, PA6, PA5);

#define RREF 430.0
#define RNOMINAL 100.0

void setup(){

  Serial.begin(115200); pinMode(PA4,OUTPUT); 
  Serial.println("Adafruit MAX31865 PT100 Sensor Test!");
  thermo.begin(MAX31865_2WIRE); // 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);
  
}
4. Serial monitor

Code: Select all

17:36:26.180 -> RTD value: 32767
17:36:26.180 -> Ratio = 0.99996948
17:36:26.180 -> Resistance = 429.98687744
17:36:26.180 -> Temperature = -242.02
17:36:26.272 -> 
17:36:27.364 -> RTD value: 28640
17:36:27.364 -> Ratio = 0.87402344
17:36:27.364 -> Resistance = 375.83007813
17:36:27.364 -> Temperature = 988.79
17:36:27.409 -> Fault 0xFF
17:36:27.409 -> RTD High Threshold
17:36:27.409 -> RTD Low Threshold
17:36:27.409 -> REFIN- > 0.85 x Bias
17:36:27.409 -> REFIN- < 0.85 x Bias - FORCE- open
17:36:27.409 -> RTDIN- < 0.85 x Bias - FORCE- open
17:36:27.409 -> Under/Over voltage
17:36:27.409 -> 
17:36:28.505 -> RTD value: 0
17:36:28.505 -> Ratio = 0.00000000
17:36:28.505 -> Resistance = 0.00000000
17:36:28.505 -> Temperature = -242.02
17:36:28.595 -> 
17:36:29.645 -> RTD value: 32767
17:36:29.645 -> Ratio = 0.99996948
17:36:29.645 -> Resistance = 429.98687744
17:36:29.645 -> Temperature = -242.02
17:36:29.735 -> Fault 0xFF
17:36:29.735 -> RTD High Threshold
17:36:29.735 -> RTD Low Threshold
17:36:29.735 -> REFIN- > 0.85 x Bias
17:36:29.735 -> REFIN- < 0.85 x Bias - FORCE- open
17:36:29.735 -> RTDIN- < 0.85 x Bias - FORCE- open
17:36:29.735 -> Under/Over voltage
17:36:29.735 -> 
17:36:30.828 -> RTD value: 0
17:36:30.828 -> Ratio = 0.00000000
17:36:30.828 -> Resistance = 0.00000000
17:36:30.828 -> Temperature = 988.79
17:36:30.874 -> Fault 0xFF
17:36:30.874 -> RTD High Threshold
17:36:30.874 -> RTD Low Threshold
17:36:30.874 -> REFIN- > 0.85 x Bias
17:36:30.874 -> REFIN- < 0.85 x Bias - FORCE- open
17:36:30.874 -> RTDIN- < 0.85 x Bias - FORCE- open
17:36:30.874 -> Under/Over voltage
Q1) Is it possible to use 'maple mini' and 'Adafruit_MAX31865'?

Q2) Or did I make a mistake?

Re: [maple mini] Adafruit_MAX31865 library : The correct value is not displayed.

Posted: Wed Nov 20, 2024 8:41 am
by myksj1105

Re: [maple mini] Adafruit_MAX31865 library : The correct value is not displayed.

Posted: Wed Nov 20, 2024 8:53 am
by fpiSTM
I would tell yes.
Anyway, there is an issue with Adafruit library SPI.
They consider pin as int and not uint.
I guess you met this issue.

Instead of using the alias PAx for the pins use their pin number:

Code: Select all

-Adafruit_MAX31865 thermo = Adafruit_MAX31865(PA4, PA7, PA6, PA5);
+Adafruit_MAX31865 thermo = Adafruit_MAX31865(7, 4, 5, 6);
Here same issue with https://github.com/adafruit/Adafruit-GF ... y/pull/359


But maybe not your issue :mrgreen:

Re: [maple mini] Adafruit_MAX31865 library : The correct value is not displayed.

Posted: Thu Nov 21, 2024 12:18 am
by myksj1105
@fpiSTM


Thank you. ~~!!

Re: [maple mini] Adafruit_MAX31865 library : The correct value is not displayed.

Posted: Thu Nov 21, 2024 10:15 am
by fpiSTM
myksj1105 wrote: Thu Nov 21, 2024 12:18 am @fpiSTM


Thank you. ~~!!
Welcome @myksj1105 .
Do not hesitate to provide your feedback to Adafruit MAX31865 library.

Re: [maple mini] Adafruit_MAX31865 library : The correct value is not displayed.

Posted: Mon Nov 25, 2024 5:44 am
by myksj1105

Code: Select all

Adafruit_MAX31865 thermo = Adafruit_MAX31865(7, 4, 5, 6);
It seems that SPI communication is working, but the actual result value is not correct.
I am looking for another library.

Code: Select all

14:43:45.948 -> REFIN- < 0.85 x Bias - FORCE- open
14:43:45.948 -> RTDIN- < 0.85 x Bias - FORCE- open
14:43:45.948 -> Under/Over voltage
14:43:45.948 -> 
14:43:46.991 -> 988.79
14:43:46.991 -> Fault 0xFF
14:43:46.991 -> RTD High Threshold
14:43:46.991 -> RTD Low Threshold
14:43:46.991 -> REFIN- > 0.85 x Bias
14:43:46.991 -> REFIN- < 0.85 x Bias - FORCE- open
14:43:46.991 -> RTDIN- < 0.85 x Bias - FORCE- open
14:43:46.991 -> Under/Over voltage
14:43:46.991 -> 
14:43:48.084 -> 988.79
14:43:48.084 -> Fault 0xFF
14:43:48.084 -> RTD High Threshold
14:43:48.084 -> RTD Low Threshold
14:43:48.084 -> REFIN- > 0.85 x Bias
14:43:48.084 -> REFIN- < 0.85 x Bias - FORCE- open
14:43:48.084 -> RTDIN- < 0.85 x Bias - FORCE- open
14:43:48.084 -> Under/Over voltage
14:43:48.084 -> 
14:43:49.180 -> 988.79
14:43:49.180 -> Fault 0xFF
14:43:49.180 -> RTD High Threshold
14:43:49.180 -> RTD Low Threshold
14:43:49.180 -> REFIN- > 0.85 x Bias
14:43:49.180 -> REFIN- < 0.85 x Bias - FORCE- open
14:43:49.180 -> RTDIN- < 0.85 x Bias - FORCE- open
14:43:49.180 -> Under/Over voltage
14:43:49.180 -> 
14:43:50.270 -> 988.79
14:43:50.270 -> Fault 0xFF
14:43:50.270 -> RTD High Threshold
14:43:50.270 -> RTD Low Threshold
14:43:50.270 -> REFIN- > 0.85 x Bias
14:43:50.270 -> REFIN- < 0.85 x Bias - FORCE- open
14:43:50.270 -> RTDIN- < 0.85 x Bias - FORCE- open
14:43:50.270 -> Under/Over voltage
14:43:50.270 -> 

If you change the PIN number, it will be expressed as the same value as below. However, it is not the 'true value'.

Re: [maple mini] Adafruit_MAX31865 library : The correct value is not displayed.

Posted: Mon Jan 06, 2025 1:49 am
by myksj1105
No matter how hard I try, it doesn't work.
Can someone help me?

Even if I use 'Adafruit_MAX31865(7, 4, 5, 6)', the exact value does not come out.
It seems to be a problem with the library code.

Re: [maple mini] Adafruit_MAX31865 library : The correct value is not displayed.

Posted: Mon Jan 06, 2025 4:02 am
by myksj1105
@@fpiSTM

https://github.com/rogerclarkmelbourne/ ... /board.cpp



'Adafruit_MAX31865(7, 4, 5, 6);'
Why?
'Adafruit_MAX31865(4,7,6,5);'
Why? 7,4,5,6?

I'm curious.

Re: [maple mini] Adafruit_MAX31865 library : The correct value is not displayed.

Posted: Mon Jan 06, 2025 5:30 am
by ag123
https://github.com/adafruit/Adafruit_MA ... MAX31865.h

Code: Select all

class Adafruit_MAX31865 {
public:
  Adafruit_MAX31865(int8_t spi_cs, int8_t spi_mosi, int8_t spi_miso,
                    int8_t spi_clk);
  Adafruit_MAX31865(int8_t spi_cs, SPIClass *theSPI = &SPI);
https://github.com/rogerclarkmelbourne/ ... oard.h#L51

Code: Select all

#define BOARD_SPI1_NSS_PIN        PA4
#define BOARD_SPI1_MOSI_PIN       PA7
#define BOARD_SPI1_MISO_PIN       PA6
#define BOARD_SPI1_SCK_PIN        PA5
so
------------------

Code: Select all

// use ss pin for cs
Adafruit_MAX31865 thermo(PA4, SPI);
or

Code: Select all

Adafruit_MAX31865 thermo(PA4, PA7, PA6, PA5);
this should work in either core
---------
Adafruit_MAX31865 thermo = likely won't work, stack, ram and all those issues, if one wants to investigate needs to review or debug the assembly code.