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

Substitute pow(a,b) with exp(b*log(a)) to make it compatible with ESP… #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions Adafruit_BMP085_U.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,10 @@ float Adafruit_BMP085_Unified::pressureToAltitude(float seaLevel, float atmosphe
// at high altitude. See this thread for more information:
// http://forums.adafruit.com/viewtopic.php?f=22&t=58064

return 44330.0 * (1.0 - pow(atmospheric / seaLevel, 0.1903));
// return 44330.0 * (1.0 - pow(atmospheric / seaLevel, 0.1903));
// Pow is not compatible with ESP8266 Arduino IDE. This is a workaround
// See http://stackoverflow.com/questions/4985221/how-will-you-implement-powa-b-in-c-condition-follows
return 44330.0 * (1.0 - exp(0.1903 * log(atmospheric / seaLevel)));
}

/**************************************************************************/
Expand Down Expand Up @@ -410,7 +413,10 @@ float Adafruit_BMP085_Unified::seaLevelForAltitude(float altitude, float atmosph
// 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);
// return atmospheric / pow(1.0 - (altitude/44330.0), 5.255);
// Pow is not compatible with ESP8266 Arduino IDE. This is a workaround
// See http://stackoverflow.com/questions/4985221/how-will-you-implement-powa-b-in-c-condition-follows
return atmospheric / exp(5.255 * log(1.0 - (altitude/44330.0)));
}

/**************************************************************************/
Expand Down