BMP180 Pressure/Temperature Sensor library

Dependents:   GliderFuncTest1 DropTest

Fork of BMP180 by Spiridion Mbed

Revision:
2:1dad52218be5
Parent:
1:072073c79cfd
Child:
3:ae101ea7bd90
diff -r 072073c79cfd -r 1dad52218be5 BMP180.cpp
--- a/BMP180.cpp	Mon Mar 17 20:42:23 2014 +0000
+++ b/BMP180.cpp	Sun Apr 09 05:05:11 2017 +0000
@@ -11,7 +11,7 @@
   Released under the MIT License (see http://mbed.org/license/mit)
 
   Documentation regarding the BMP180 can be found here:
-  http://mbed.org/media/uploads/spiridion/bst-bmp180-ds000-09.pdf
+  
 */
 
 #include "BMP180.h"
@@ -87,7 +87,7 @@
     return errors? 0 : 1;
 }
 
-int BMP180::ReadData(float* pTemperature, float* pPressure)
+int BMP180::ReadData(float* pTemperature, float* pPressure, float* pAltitude)
 {
     long t, p;
 
@@ -105,10 +105,20 @@
         *pPressure = m_pressure;
     if (pTemperature)
         *pTemperature = m_temperature;
+    if (pAltitude)
+        *pAltitude = getAltitude(pPressure);
 
     return 1;
 }
 
+float BMP180::getAltitude(float* p) {
+    //return 44330.0 * (1.0 - pow((*p / m_altitude), (float)0.1903)); 
+    float altitude = (*p / m_altitude);
+    altitude = pow(altitude, (float)(1 / 5.255));
+    altitude = 44330 * (1 - altitude);
+    return altitude;
+}
+
 int BMP180::ReadRawTemperature(long* pUt)
 {
     int errors = 0;