Skip to content

Commit

Permalink
Merge pull request #36 from tdobrovolny/overload_temperature
Browse files Browse the repository at this point in the history
overload temperature function
  • Loading branch information
caternuson authored Jun 21, 2022
2 parents a551f49 + b37cf46 commit 4fecc8c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Adafruit_MAX31865.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,27 @@ void Adafruit_MAX31865::setWires(max31865_numwires_t wires) {
*/
/**************************************************************************/
float Adafruit_MAX31865::temperature(float RTDnominal, float refResistor) {
return calculateTemperature(readRTD(), RTDnominal, refResistor);
}
/**************************************************************************/
/*!
@brief Calculate the temperature in C from the RTD through calculation of
the resistance. Uses
http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf
technique
@param RTDraw The raw 16-bit value from the RTD_REG
@param RTDnominal The 'nominal' resistance of the RTD sensor, usually 100
or 1000
@param refResistor The value of the matching reference resistor, usually
430 or 4300
@returns Temperature in C
*/
/**************************************************************************/
float Adafruit_MAX31865::calculateTemperature(uint16_t RTDraw, float RTDnominal,
float refResistor) {
float Z1, Z2, Z3, Z4, Rt, temp;

Rt = readRTD();
Rt = RTDraw;
Rt /= 32768;
Rt *= refResistor;

Expand Down
2 changes: 2 additions & 0 deletions Adafruit_MAX31865.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class Adafruit_MAX31865 {
void enableBias(bool b);

float temperature(float RTDnominal, float refResistor);
float calculateTemperature(uint16_t RTDraw, float RTDnominal,
float refResistor);

private:
Adafruit_SPIDevice spi_dev;
Expand Down

0 comments on commit 4fecc8c

Please sign in to comment.