Arduino drives MAX31865 to read platinum resistor temperature

Preface

The MAX31865 is an easy-to-use thermistor to digital output converter optimized for platinum resistance temperature detectors (RTDs). An external resistor sets the RTD sensitivity, and a high-precision delta-sigma ADC converts the ratio of the RTD resistance to the reference resistance to a digital output. The MAX31865 input is protected against overvoltage up to ±45V and provides configurable detection of RTD and cable open and short-circuit conditions.

Hardware usage

Insert image description here
Insert image description here

Electrical parameters

1. Supports 100Ω to 1kΩ (at 0°C) platinum resistance RTD (PT100 to PT1000);
2. Compatible with 2-wire, 3-wire and 4-wire sensor connections;
3. SPI compatible interface;
4. 15-bit ADC resolution, nominal Temperature resolution is 0.03125°C (varies non-linearly with RTD);
5. Total accuracy remains at 0.5°C (0.05% full scale) over the entire operating condition;
6 Fully differential VREF input;
7. Conversion time: 21ms (max value);
8. Integrated fault detection to increase system stability: (RTD open circuit, RTD short circuit to voltage outside the range or RTD component short circuit).

Application circuit and timing diagram

Application circuit:
Insert image description here
SPI timing:
Insert image description here
Insert image description here

Temperature conversion

Resistance temperature detectors (RTDs) are sensors whose resistance changes with temperature. Platinum is the most common and most accurate wire; platinum RTDs are called PT-RTDs. Nickel, copper and other metals can also be used to make RTDs. Features of Platinum RTDs include temperature range (over +800°C), excellent accuracy, and reasonable linearity. For PT-RTDs, the most common nominal value 0°C resistors are 100Ω and 1kΩ, although other values ​​are available. The average slope between 0°C and +100°C is called alpha (α). This value depends on the impurities in the platinum and their concentration. The two most widely used values ​​for alpha are 0.00385 and 0.00392, corresponding to the IEC 751 (PT100) and SAMA standards. The resistance versus temperature curve is fairly linear, but has some curvature, as described by the CallendarVan Dusen equation:
             R(T) = R0(1 + aT + bT2 + c(T - 100)T3)
 where
Insert image description here

Wiring diagram

Arduino MAX31865 LCD 1602
5V VCC VCC
GND GND GND
11 CLK -
10 SDO -
9 SDI -
8 CS -
A4 - SDA
A5 - SCL

program

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

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display

// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31865 max = Adafruit_MAX31865(8,9,10,11);
// use hardware SPI, just pass in the CS pin
//Adafruit_MAX31865 max = Adafruit_MAX31865(10);

// The value of the Rref resistor. Use 430.0!
#define RREF 430.0


void setup() {
    
    
  Serial.begin(115200);
  Serial.println("Adafruit MAX31865 PT100 Sensor Test!");
  lcd.init(); //初始化LCD
  lcd.backlight();  //打开LCD背光
  max.begin(MAX31865_3WIRE);  // set to 2WIRE or 4WIRE as necessary
}


void loop() {
    
    
  uint16_t rtd = max.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(max.temperature(100, RREF));
  lcd.setCursor(1,0);   
  lcd.print("Res= ");   
  lcd.setCursor(5,0);  
  lcd.print(RREF*ratio,3);     
  lcd.setCursor(1,1);   
  lcd.print("Tem= ");   
  lcd.setCursor(5,1);  
  lcd.print(max.temperature(100, RREF));  
  lcd.setCursor(10,1);   
  lcd.print("C "); 
  // Check and print any faults
  uint8_t fault = max.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"); 
    }
    max.clearFault();
  }
  Serial.println();
  delay(1000);
}

result

Serial port display:
Insert image description here

LCD display:
Insert image description here

Summarize

Note: When using a 3-wire PT100 sensor probe, you need to short-circuit the 2/3Wire solder joints. At the same time, cut the left solder joint from the middle above Rref, and short-circuit the right solder joint marked with 3 with the middle solder joint.

Guess you like

Origin blog.csdn.net/qq_42250136/article/details/133342472