Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: BMP085.cpp
- Revision:
- 1:bd3f19ce9849
- Parent:
- 0:0b4c4632aeb0
--- a/BMP085.cpp Wed Dec 12 16:30:14 2012 +0000
+++ b/BMP085.cpp Thu Apr 22 03:44:05 2021 +0000
@@ -50,7 +50,7 @@
void BMP085::init()
{
get_cal_param();
- set_oss(8); // standard over sampling (2 samples)
+ set_oss(1); // standard over sampling (2 samples)
get_ut(); // initalize values
get_up();
}
@@ -188,14 +188,14 @@
x1 = ((UT - AC6) * AC5) >> 15;
x2 = (MC << 11) / (x1 + MD);
B5 = x1 + x2;
- temperature = ((B5 + 8) >> 4);
+ temperature = ((B5 + 8) >> 4)/10;
return temperature;
}
int32_t BMP085::get_pressure()
{
get_up(); // get uncompressed pressure (uncompressed temperature must be called recently)
-
+ get_ut(); // uncompressed temperature
B6 = B5 - 4000;
X1 = (B2 * ((B6 * B6) >> 12)) >> 11;
X2 = (AC2 * B6) >> 11;
@@ -222,9 +222,10 @@
double BMP085::get_altitude_m()
{
+ get_pressure();
const double P0 = 1013.25; //pressure at sea level in hPa
double pres_hpa = pressure / 100.0;
- altitude = 44330.0 * (1.0 - pow((pres_hpa/P0), 0.190295));
+ altitude = (44330.0 * (1.0 - pow((pres_hpa/P0), 0.1903)));
return altitude;
}