BD1020HFV Temperature sensor test code
Dependencies: mbed
Revision 2:913fc12a42a7, committed 2016-09-21
- Comitter:
- MikkoZ
- Date:
- Wed Sep 21 09:57:41 2016 +0000
- Parent:
- 1:ba7e525074f9
- Commit message:
- Alternative temperature formula added.; ; - Added temperature formula; - Added comments about values used in both formulas; ; Tested on GR-Peach + Rohm tile shield + BD1020 on analog_2 connector
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r ba7e525074f9 -r 913fc12a42a7 main.cpp --- a/main.cpp Thu Sep 08 11:13:51 2016 +0000 +++ b/main.cpp Wed Sep 21 09:57:41 2016 +0000 @@ -4,11 +4,22 @@ AnalogIn sensor(A2); int main() { - float temparature; - pc.printf("\nBD1020HFV Temperature sensor test program.\n"); + float temperature1; + float temperature2; + pc.printf("\n\r"); + pc.printf("BD1020HFV Temperature sensor test program.\n\r"); + pc.printf("All values are approximates based on specification graph.\n\r"); + pc.printf("Formula values should be calibrated before use.\n\r"); while(1) { - temparature = -(1000 * (sensor * 3.3f) - 1546) / 8.2; - pc.printf("Temperature=%5.3f\r\n", temparature); - wait(0.4); + //Input voltage 0-3.3V == 0.0-1.0f + //-40'C == 1.87V + // 0'C == 1.546V + //192'C == 0V (out of scale) + //1.87V / 232'C = 0.008060V/'C + + temperature1 = -(1000 * (sensor * 3.3f) - 1546) / 8.2; + temperature2 = 192 - ( sensor * 3.3f / 0.008060 ); + pc.printf("Temperature, formula1=%5.3f, formula2=%5.3f\r\n", temperature1, temperature2); + wait(1); } }