temperature and distance

Fork of TrashSensors by Corey Ford

Revision:
1:9cd59726cc5e
Parent:
0:3f335fc50cef
--- a/GroveTemp.cpp	Sun May 24 20:45:32 2015 +0000
+++ b/GroveTemp.cpp	Thu May 28 23:11:33 2015 +0000
@@ -2,6 +2,8 @@
 #include <math.h>
 #include "GroveTemp.h"
 //
+#define CALIBRATE_FACTOR_5V 0.66
+
 AnalogIn thermistor(A0);   /* Temperature sensor connected to Analog Grove connector */
 
 GroveTempSensor::GroveTempSensor() {
@@ -13,7 +15,7 @@
 //                units, 
 //                tens;
     
-   analogRead = thermistor.read_u16(); /* Read analog value */
+   analogRead = thermistor.read_u16() * CALIBRATE_FACTOR_5V; /* Read analog value */
    
    /* Calculate the resistance of the thermistor from analog votage read. */
    resistance = (float) 10000.0 * ((65536.0 / analogRead) - 1.0);