Skip to content

Commit 83027ec

Browse files
committed
fix for PT1000 negative temp calculation
1 parent d59fe8c commit 83027ec

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

Adafruit_MAX31865.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ float Adafruit_MAX31865::temperature(float RTDnominal, float refResistor) {
122122
Rt /= 32768;
123123
Rt *= refResistor;
124124

125-
//Serial.print("Resistance: "); Serial.println(Rt, 8);
125+
// Serial.print("\nResistance: "); Serial.println(Rt, 8);
126126

127127
Z1 = -RTD_A;
128128
Z2 = RTD_A * RTD_A - (4 * RTD_B);
@@ -135,6 +135,9 @@ float Adafruit_MAX31865::temperature(float RTDnominal, float refResistor) {
135135
if (temp >= 0) return temp;
136136

137137
// ugh.
138+
Rt /= RTDnominal;
139+
Rt *= 100; // normalize to 100 ohm
140+
138141
float rpoly = Rt;
139142

140143
temp = -242.02;

examples/max31865/max31865.ino

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ Adafruit_MAX31865 max = Adafruit_MAX31865(10, 11, 12, 13);
2121
// use hardware SPI, just pass in the CS pin
2222
//Adafruit_MAX31865 max = Adafruit_MAX31865(10);
2323

24-
// The value of the Rref resistor. Use 430.0!
25-
#define RREF 430.0
26-
24+
// The value of the Rref resistor. Use 430.0 for PT100 and 4300.0 for PT1000
25+
#define RREF 430.0
26+
// The 'nominal' 0-degrees-C resistance of the sensor
27+
// 100.0 for PT100, 1000.0 for PT1000
28+
#define RNOMINAL 100.0
2729

2830
void setup() {
2931
Serial.begin(115200);
@@ -41,7 +43,7 @@ void loop() {
4143
ratio /= 32768;
4244
Serial.print("Ratio = "); Serial.println(ratio,8);
4345
Serial.print("Resistance = "); Serial.println(RREF*ratio,8);
44-
Serial.print("Temperature = "); Serial.println(max.temperature(100, RREF));
46+
Serial.print("Temperature = "); Serial.println(max.temperature(RNOMINAL, RREF));
4547

4648
// Check and print any faults
4749
uint8_t fault = max.readFault();

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit MAX31865 library
2-
version=1.0.0
2+
version=1.0.1
33
author=Adafruit
44
maintainer=Adafruit <[email protected]>
55
sentence=Library for the Adafruit RTD Amplifier breakout with MAX31865

0 commit comments

Comments
 (0)