BD1020HFV Temperature sensor test code
Dependencies: mbed
Diff: main.cpp
- Revision:
- 2:913fc12a42a7
- Parent:
- 1:ba7e525074f9
--- 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); } }