
Seeedstudio Arch Examples : Temperature sensing using thermistor and AnalogIn interface.
Fork of Arch_GPIO_Ex4 by
Diff: main.cpp
- Revision:
- 6:914bd412ceda
- Parent:
- 5:d035275d4c21
--- a/main.cpp Mon Oct 07 13:10:03 2013 +0000 +++ b/main.cpp Tue Oct 08 08:53:33 2013 +0000 @@ -1,5 +1,4 @@ #include "mbed.h" -#include "USBSerial.h" AnalogIn thermistor(P0_11); /* Thermistor output connected to P0_11 */ @@ -15,7 +14,7 @@ a = thermistor.read_u16(); /* Read analog value */ /* Calculate the resistance of the thermistor from analog votage read. */ - resistance= (float) 10000.0 * (1.0 - (a / 65536.0 )); + resistance= (float) 10000.0 * ((65536.0 / a) - 1.0); /* Convert the resistance to temperature using Steinhart's Hart equation */ temperature=(1/((log(resistance/5000.0)/beta) + (1.0/298.15)))-273.15;