@@ -41,7 +41,8 @@ const MAX31855Class::coefftable MAX31855Class::InvCoeffK[];
4141MAX31855Class::MAX31855Class (int cs, SPIClass& spi) :
4242 _cs(cs),
4343 _spi(&spi),
44- _spiSettings(4000000 , MSBFIRST, SPI_MODE0)
44+ _spiSettings(4000000 , MSBFIRST, SPI_MODE0),
45+ _coldOffset(2 .10f )
4546{
4647}
4748
@@ -194,8 +195,7 @@ float MAX31855Class::readTemperature(int type)
194195 }
195196
196197 // convert it to degrees
197- measuredCold = measuredColdInt/16 .0f ;
198-
198+ measuredCold = (measuredColdInt/16 .0f );
199199 // now the tricky part... since MAX31855K is considering a linear response
200200 // and is trimemd for K thermocouples, we have to convert the reading back
201201 // to mV and then use NIST polynomial approximation to determine temperature
@@ -208,7 +208,7 @@ float MAX31855Class::readTemperature(int type)
208208 // this way we calculate the voltage we would have measured if cold junction
209209 // was at 0 degrees celsius
210210
211- measuredVolt = coldTempTomv (type, measuredCold)+(measuredTemp- measuredCold) * 0 .041276f ;
211+ measuredVolt = coldTempTomv (type, measuredCold - _coldOffset )+(measuredTemp - measuredCold) * 0 .041276f ;
212212
213213 // finally from the cold junction compensated voltage we calculate the temperature
214214 // using NIST polynomial approximation for the thermocouple type we are using
@@ -239,4 +239,9 @@ float MAX31855Class::readReferenceTemperature(int type)
239239 return ref;
240240}
241241
242+ void MAX31855Class::setColdOffset (float offset)
243+ {
244+ _coldOffset = offset;
245+ }
246+
242247MAX31855Class THERM;
0 commit comments