Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of analoghalls6 by
Diff: tempsensors.cpp
- Revision:
- 0:54cf32d35f4d
- Child:
- 1:1f58bdcf2956
diff -r 000000000000 -r 54cf32d35f4d tempsensors.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tempsensors.cpp Sun Mar 01 06:16:01 2015 +0000 @@ -0,0 +1,15 @@ +#include "includes.h" +#include "classes.h" + +NtcTempSensor::NtcTempSensor(PinName pin, float r_25, float ntc_b, float r_divider) { + _in = new AnalogIn(pin); + _ntc_b = ntc_b; + _ntc_a = r_25 / exp(_ntc_b / 298.0f); + _r_divider = r_divider; +} + +float NtcTempSensor::GetTemp() { + float v = (float) *_in * 3.3f; + float r_n = v * _r_divider / (1.0f + v); + return _ntc_b / log (r_n / _ntc_a); +} \ No newline at end of file