temperature and distance
Fork of TrashSensors by
Revision 1:9cd59726cc5e, committed 2015-05-28
- Comitter:
- Luminoscity
- Date:
- Thu May 28 23:11:33 2015 +0000
- Parent:
- 0:3f335fc50cef
- Commit message:
- Calibration at 5V;
Changed in this revision
GroveTemp.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 3f335fc50cef -r 9cd59726cc5e GroveTemp.cpp --- 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);