th
Dependents: condato_Coldchainlogger condato_Coldchainlogger
Revision 2:374faf195af3, committed 2020-07-09
- Comitter:
- condato_mbed
- Date:
- Thu Jul 09 15:56:36 2020 +0000
- Parent:
- 1:601e1435dfb8
- Commit message:
- thermistor
Changed in this revision
Thermistor.cpp | Show annotated file Show diff for this revision Revisions of this file |
Thermistor.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 601e1435dfb8 -r 374faf195af3 Thermistor.cpp --- a/Thermistor.cpp Wed Mar 09 13:56:37 2016 +0000 +++ b/Thermistor.cpp Thu Jul 09 15:56:36 2020 +0000 @@ -27,7 +27,7 @@ SeriesResistor = SERIESRESISTOR; } - // This is the workhorse routine that calculates the temperature + // This is the workhorse routine that calculates the temperature // using the Steinhart-Hart equation for thermistors // https://en.wikipedia.org/wiki/Steinhart%E2%80%93Hart_equation float Thermistor::get_temperature() @@ -41,11 +41,11 @@ a += _pin.read_u16(); // Read 16bit Analog value } a = a/smooth; // Get average of samples - // pc.printf("Raw Analog Value for Thermistor = %d\r\n",a); + //printf("Raw Analog Value for Thermistor = %d\r\n",a); /* Calculate the resistance of the thermistor from analog votage read. */ resistance = (float) SeriesResistor / ((65536.0 / a) - 1); - // pc.printf("Resistance for Thermistor = %f\r\n",resistance); + //printf("Resistance for Thermistor = %f\r\n",resistance); steinhart = resistance / ThermistorNominal; // (R/Ro) steinhart = log(steinhart); // ln(R/Ro)
diff -r 601e1435dfb8 -r 374faf195af3 Thermistor.h --- a/Thermistor.h Wed Mar 09 13:56:37 2016 +0000 +++ b/Thermistor.h Thu Jul 09 15:56:36 2020 +0000 @@ -78,13 +78,13 @@ #include "mbed.h" -#define THERMISTORNOMINAL 100000 // 100k default +#define THERMISTORNOMINAL 10000 // 100k default // temp. for nominal resistance (almost always 25 C) -#define TEMPERATURENOMINAL 25 +#define TEMPERATURENOMINAL 25 // The beta coefficient of the thermistor (usually 3000-4000) #define BCOEFFICIENT 3950 // the value of the 'other' resistor -#define SERIESRESISTOR 4700 +#define SERIESRESISTOR 4700 class Thermistor { @@ -93,7 +93,7 @@ /** Receives a PinName variable. * @param pin mbed pin to which the thermistor is connected */ - + float get_temperature(); /** This is the workhorse routine that calculates the temperature