Merge pull request #11 from mozzbozz/master

Added sea level pressure calculation helper function
This commit is contained in:
Limor "Ladyada" Fried 2016-08-16 14:31:42 -04:00 committed by GitHub
commit 3b54af67d0
2 changed files with 21 additions and 0 deletions

View File

@ -378,3 +378,23 @@ float Adafruit_BME280::readAltitude(float seaLevel)
float atmospheric = readPressure() / 100.0F; float atmospheric = readPressure() / 100.0F;
return 44330.0 * (1.0 - pow(atmospheric / seaLevel, 0.1903)); return 44330.0 * (1.0 - pow(atmospheric / seaLevel, 0.1903));
} }
/**************************************************************************/
/*!
Calculates the pressure at sea level (in hPa) from the specified altitude
(in meters), and atmospheric pressure (in hPa).
@param altitude Altitude in meters
@param atmospheric Atmospheric pressure in hPa
*/
/**************************************************************************/
float Adafruit_BME280::seaLevelForAltitude(float altitude, float atmospheric)
{
// Equation taken from BMP180 datasheet (page 17):
// http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf
// Note that using the equation from wikipedia can give bad results
// at high altitude. See this thread for more information:
// http://forums.adafruit.com/viewtopic.php?f=22&t=58064
return atmospheric / pow(1.0 - (altitude/44330.0), 5.255);
}

View File

@ -135,6 +135,7 @@ class Adafruit_BME280
float readPressure(void); float readPressure(void);
float readHumidity(void); float readHumidity(void);
float readAltitude(float seaLevel); float readAltitude(float seaLevel);
float seaLevelForAltitude(float altitude, float atmospheric);
private: private: