testing ms5637 library

Dependencies:   MS5637 mbed

Committer:
cstevens
Date:
Tue May 20 16:19:08 2014 +0000
Revision:
0:dd89d33da7c8
test for ms5637 barometer with dodgy calibration

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cstevens 0:dd89d33da7c8 1 #include "mbed.h"
cstevens 0:dd89d33da7c8 2 #include "ms5637.h"
cstevens 0:dd89d33da7c8 3
cstevens 0:dd89d33da7c8 4 ms5637 ms(PTE0, PTE1); // i2c pins used
cstevens 0:dd89d33da7c8 5 Serial pc(USBTX, USBRX); // local terminal interface
cstevens 0:dd89d33da7c8 6
cstevens 0:dd89d33da7c8 7
cstevens 0:dd89d33da7c8 8 int main (void)
cstevens 0:dd89d33da7c8 9 {
cstevens 0:dd89d33da7c8 10 pc.baud(9600); // set up USB serial speed
cstevens 0:dd89d33da7c8 11
cstevens 0:dd89d33da7c8 12 // set up the ms5611
cstevens 0:dd89d33da7c8 13 pc.printf("\n\nInitializing the MS5611..\n\r");
cstevens 0:dd89d33da7c8 14 ms.cmd_reset();
cstevens 0:dd89d33da7c8 15 pc.printf("Ready new\n\r");
cstevens 0:dd89d33da7c8 16
cstevens 0:dd89d33da7c8 17 while(1) {
cstevens 0:dd89d33da7c8 18 double Temp = ms.calcTemp(); //calculate press and temp, then returns current temperature in degC
cstevens 0:dd89d33da7c8 19 double Press = ms.calcPressure(); //calculate press and temp, then returns current pressure in mb
cstevens 0:dd89d33da7c8 20 double GetPress = ms.getPressure(); //returns current pressure in mb. Does no calculations. Ususally done after calcTemp()
cstevens 0:dd89d33da7c8 21 double Altitude = ms.getAltitudeFT(1013.25); //enter pressure at sea level in mb, returns altitude in feet
cstevens 0:dd89d33da7c8 22 double PressSeaLvlFT = ms.getSeaLevelBaroFT(327.2); //enter known altitude in feet, returns sea level pressure in mb
cstevens 0:dd89d33da7c8 23 double PressSeaLvlM = ms.getAltitudeFT(99.73); //enter known altitude in meters, returns seal level pressure in mb
cstevens 0:dd89d33da7c8 24
cstevens 0:dd89d33da7c8 25 pc.printf("Temp: %.2f degC - ", Temp);
cstevens 0:dd89d33da7c8 26 pc.printf("Barometer: %.1f mB %.3f in/Hg - \r", Press, Press * 0.0295301);
cstevens 0:dd89d33da7c8 27 // pc.printf("Alt: %.1f ft - ", Altitude);
cstevens 0:dd89d33da7c8 28 // pc.printf("Sea_Lvl: %.1f ft %.2f m\r", PressSeaLvlFT, PressSeaLvlM);
cstevens 0:dd89d33da7c8 29 wait(2.0);
cstevens 0:dd89d33da7c8 30 }
cstevens 0:dd89d33da7c8 31 }
cstevens 0:dd89d33da7c8 32
cstevens 0:dd89d33da7c8 33