the code uses an NTC thermistor to measure the respiration rate.

Committer:
moe414
Date:
Sat May 26 03:59:57 2018 +0000
Revision:
0:eefa433e1005
Respiration sensor using a Thermistor

Who changed what in which revision?

UserRevisionLine numberNew contents of line
moe414 0:eefa433e1005 1
moe414 0:eefa433e1005 2 //this function is programmed to take the analong voltage value and convert it to temperature.
moe414 0:eefa433e1005 3 float tempinf(float sensor) {
moe414 0:eefa433e1005 4 // first it will convert the voltage to resistance
moe414 0:eefa433e1005 5 double R_ratio = (1/sensor- 1);
moe414 0:eefa433e1005 6 double logR_ratio=log(R_ratio);
moe414 0:eefa433e1005 7 //the next line will convert the resistance to temperatue in Kelvin units using Steinhart and Hart equation.
moe414 0:eefa433e1005 8 double T_kelvin=1/(.003354016+.000256985*logR_ratio+.000002620131*logR_ratio*logR_ratio);
moe414 0:eefa433e1005 9 float T = (T_kelvin - 273);//conver the temperture to celsious
moe414 0:eefa433e1005 10 return T; // returen the temperature value.
moe414 0:eefa433e1005 11
moe414 0:eefa433e1005 12 }