LPS25H sample
Dependencies: AQM0802 LPS25H mbed
See http://developer.mbed.org/users/yasuyuki/notebook/LPS25H/
Revision 0:f7ac3f4062cf, committed 2014-10-12
- Comitter:
- yasuyuki
- Date:
- Sun Oct 12 02:44:32 2014 +0000
- Commit message:
- first release
Changed in this revision
diff -r 000000000000 -r f7ac3f4062cf AQM0802.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AQM0802.lib Sun Oct 12 02:44:32 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/yasuyuki/code/AQM0802/#6fa303916aa8
diff -r 000000000000 -r f7ac3f4062cf LPS25H.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LPS25H.lib Sun Oct 12 02:44:32 2014 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/yasuyuki/code/LPS25H/#0d2babe81a04
diff -r 000000000000 -r f7ac3f4062cf main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Oct 12 02:44:32 2014 +0000 @@ -0,0 +1,71 @@ +//********************** +// Barometer and Altimeter +// LPS25H sample for mbed +// +// LPC1768 flash=512KB, ADC=12bits +// LPC11U35 flash=64KB, ADC=10bits +// Nucleo ADC=12bits +// +// (C)Copyright 2014 All rights reserved by Y.Onodera +// http://einstlab.web.fc2.com +//********************** +#include "mbed.h" +#include "AQM0802.h" +#include "LPS25H.h" + +#if defined(TARGET_LPC1768) +I2C i2c(p28,p27); +#endif +// for TG-LPC11U35-501 +#if defined(TARGET_LPC11U35_501) +I2C i2c(P0_5,P0_4); +#endif +// for Nucleo +#if defined(TARGET_NUCLEO_F401RE) +I2C i2c(D14,D15); +#endif + +AQM0802 lcd(i2c); +LPS25H lps25h(i2c); + +#define T0 288.15 +#define dT 0.0065 +#define P0 101325.0 +#define g 9.80665 +#define R 287.052 +double GetAltitude(double p, double t){ + + return (t+273.15)/dT*(pow((P0/p),dT*R/g)-1); + +} + +int main() { + + char msg[10]; + int p, t, a; + + sprintf(msg,"Barometer"); + lcd.locate(0,0); + lcd.print(msg); + sprintf(msg,"Altimeter"); + lcd.locate(0,1); + lcd.print(msg); + wait(1); + + while(1) { + + p = (double)lps25h.pressure()/40.96; + t = 42.5 + (double)lps25h.temperature()/480.0; + a = GetAltitude(p,t); + + sprintf(msg,"%6dPa",p); + lcd.locate(0,0); + lcd.print(msg); + sprintf(msg,"%4dm%2dC", a, t); + lcd.locate(0,1); + lcd.print(msg); + wait(1); + } + +} +
diff -r 000000000000 -r f7ac3f4062cf mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Oct 12 02:44:32 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file