Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add another function, which will return seaLevelPressure for a given height #3

Merged
merged 2 commits into from
Feb 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Adafruit_BMP085_U.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,22 @@ float Adafruit_BMP085_Unified::pressureToAltitude(float seaLevel, float atmosphe
* (temp + 273.15F)) / 0.0065F;
}

float Adafruit_BMP085_Unified::seaLevelForAltitude(float altitude, float atmospheric, float temp)
{
/* Hyposometric formula: */
/* */
/* P0=((((h*0.0065)/(temp + 273.15F))+1)^(^/0.190223F))*P */
/* */
/* where: h = height (in meters) */
/* P0 = sea-level pressure (in hPa) */
/* P = atmospheric pressure (in hPa) */
/* T = temperature (in �C) */

return (float)pow((((altitude*0.0065)/(temp + 273.15F))+1), (1.0/0.190223F))*atmospheric;
}



/**************************************************************************/
/*!
@brief Provides the sensor_t data for this sensor
Expand Down
1 change: 1 addition & 0 deletions Adafruit_BMP085_U.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class Adafruit_BMP085_Unified : public Adafruit_Sensor
void getTemperature(float *temp);
void getPressure(float *pressure);
float pressureToAltitude(float seaLevel, float atmospheric, float temp);
float seaLevelForAltitude(float altitude, float atmospheric, float temp);
void getEvent(sensors_event_t*);
void getSensor(sensor_t*);

Expand Down