@@ -41,7 +41,8 @@ const MAX31855Class::coefftable MAX31855Class::InvCoeffK[];
41
41
MAX31855Class::MAX31855Class (int cs, SPIClass& spi) :
42
42
_cs(cs),
43
43
_spi(&spi),
44
- _spiSettings(4000000 , MSBFIRST, SPI_MODE0)
44
+ _spiSettings(4000000 , MSBFIRST, SPI_MODE0),
45
+ _coldOffset(2 .10f )
45
46
{
46
47
}
47
48
@@ -194,8 +195,7 @@ float MAX31855Class::readTemperature(int type)
194
195
}
195
196
196
197
// convert it to degrees
197
- measuredCold = measuredColdInt/16 .0f ;
198
-
198
+ measuredCold = (measuredColdInt/16 .0f );
199
199
// now the tricky part... since MAX31855K is considering a linear response
200
200
// and is trimemd for K thermocouples, we have to convert the reading back
201
201
// to mV and then use NIST polynomial approximation to determine temperature
@@ -208,7 +208,7 @@ float MAX31855Class::readTemperature(int type)
208
208
// this way we calculate the voltage we would have measured if cold junction
209
209
// was at 0 degrees celsius
210
210
211
- measuredVolt = coldTempTomv (type, measuredCold)+(measuredTemp- measuredCold) * 0 .041276f ;
211
+ measuredVolt = coldTempTomv (type, measuredCold - _coldOffset )+(measuredTemp - measuredCold) * 0 .041276f ;
212
212
213
213
// finally from the cold junction compensated voltage we calculate the temperature
214
214
// using NIST polynomial approximation for the thermocouple type we are using
@@ -239,4 +239,9 @@ float MAX31855Class::readReferenceTemperature(int type)
239
239
return ref;
240
240
}
241
241
242
+ void MAX31855Class::setColdOffset (float offset)
243
+ {
244
+ _coldOffset = offset;
245
+ }
246
+
242
247
MAX31855Class THERM;
0 commit comments