Temperature library for the full project.
Revision 1:fc58ae197a88, committed 2015-12-07
- Comitter:
- ptcrews
- Date:
- Mon Dec 07 00:06:03 2015 +0000
- Parent:
- 0:a42f4353261f
- Commit message:
- Added comments.
Changed in this revision
Temp_Sensor.cpp | Show annotated file Show diff for this revision Revisions of this file |
Temp_Sensor.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r a42f4353261f -r fc58ae197a88 Temp_Sensor.cpp --- a/Temp_Sensor.cpp Sat Dec 05 07:31:46 2015 +0000 +++ b/Temp_Sensor.cpp Mon Dec 07 00:06:03 2015 +0000 @@ -1,11 +1,13 @@ #include "Temp_Sensor.h" -//function to get both the -// Using the AD22100K temperature sensor +/* Function: read + * --------------- + * Reads the temperature from the AD22100K sensor. + */ float Temp_Sensor::read() { // Convert Analog-input value to temperature + float voltage = (int)((temperature.read() * ADC_CONVERSION) * 1023); //1023 is to scale it up to the arduino read values. - float voltage = (int)((temperature.read() * ADC_CONVERSION) * 1023); float temperatureValue = (voltage * 0.217226044) - 61.1111111; // conversion factor simplified. printf("AI_Val: %f\n", temperatureValue); return temperatureValue; // 22.5 mV / °C; Ratiometric measurement, conversion valid for 5 V!
diff -r a42f4353261f -r fc58ae197a88 Temp_Sensor.h --- a/Temp_Sensor.h Sat Dec 05 07:31:46 2015 +0000 +++ b/Temp_Sensor.h Mon Dec 07 00:06:03 2015 +0000 @@ -1,10 +1,15 @@ #include "main.h" -#define ADC_CONVERSION 3.3/5.0 +#define ADC_CONVERSION 3.3/5.0 // ADC conversion ratio to get proper reading #ifndef _TEMP_SENSOR #define _TEMP_SENSOR +/* Class: Temp_Sensor + * ------------------ + * Defines the entire temp sensor interface for the AD22100K + * temperature sensor. Note: Only valid when connected to 5V. + */ class Temp_Sensor { public: Temp_Sensor(): temperature(TMP_ANALOG){}