Soyoon Kim
/
mbed_Barometer
Diff: main.cpp
- Revision:
- 0:f6f6f699ab24
- Child:
- 1:b6a29c7aeaa9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jun 29 12:12:24 2016 +0000 @@ -0,0 +1,22 @@ + +#include "mbed.h" +#include "Barometer.h" +#include "math.h" +Serial pc(USBTX, USBRX); +Barometer barometer(p28, p27); + +int main(void) +{ + float p = 0.0f, t = 0.0f, alt = 0.0f; + + while(1) { + barometer.update(); + p = barometer.get_pressure(); + t = barometer.get_temperature(); +// alt = pow((p/101325.0),(-5.25588)); //p = 101325 (1 - 2.25577 10-5 h)^5.25588 + + alt = (1.0-pow((p/101325.0),(-5.25588)))*(100000)/(2.25577); //p = 101325 (1 - 2.25577 10-5 h)^5.25588 + pc.printf("Pressure: %6.2f Temperature(c): %6.2f Altitude(m): %6.2f \r\n", p, t, alt); + } +} + \ No newline at end of file