Temperature library for the full project.
Temp_Sensor.cpp@1:fc58ae197a88, 2015-12-07 (annotated)
- Committer:
- ptcrews
- Date:
- Mon Dec 07 00:06:03 2015 +0000
- Revision:
- 1:fc58ae197a88
- Parent:
- 0:a42f4353261f
Added comments.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ptcrews | 0:a42f4353261f | 1 | #include "Temp_Sensor.h" |
ptcrews | 0:a42f4353261f | 2 | |
ptcrews | 1:fc58ae197a88 | 3 | /* Function: read |
ptcrews | 1:fc58ae197a88 | 4 | * --------------- |
ptcrews | 1:fc58ae197a88 | 5 | * Reads the temperature from the AD22100K sensor. |
ptcrews | 1:fc58ae197a88 | 6 | */ |
ptcrews | 0:a42f4353261f | 7 | float Temp_Sensor::read() { |
ptcrews | 0:a42f4353261f | 8 | // Convert Analog-input value to temperature |
ptcrews | 1:fc58ae197a88 | 9 | float voltage = (int)((temperature.read() * ADC_CONVERSION) * 1023); |
ptcrews | 0:a42f4353261f | 10 | //1023 is to scale it up to the arduino read values. |
ptcrews | 0:a42f4353261f | 11 | float temperatureValue = (voltage * 0.217226044) - 61.1111111; // conversion factor simplified. |
ptcrews | 0:a42f4353261f | 12 | printf("AI_Val: %f\n", temperatureValue); |
ptcrews | 0:a42f4353261f | 13 | return temperatureValue; // 22.5 mV / °C; Ratiometric measurement, conversion valid for 5 V! |
ptcrews | 0:a42f4353261f | 14 | } |