Skip to content

Commit ebc56a7

Browse files
committed
add some comments about "refPressure"
There are too many units and names for this, so at least provide some hints to what it means. I'm already distracted and it's Friday so I put some Sparkfun style commentary in it.
1 parent 8e57734 commit ebc56a7

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/SparkFunBME280.cpp

+14-2
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,13 @@ float BME280::readFloatPressure( void )
390390

391391
}
392392

393-
//Sets the internal variable _referencePressure so the
393+
// Sets the internal variable _referencePressure so the altitude is calculated properly.
394+
// This is also known as "sea level pressure" and is in Pascals. The value is probably
395+
// within 10% of 101325. This varies based on the weather:
396+
// https://en.wikipedia.org/wiki/Atmospheric_pressure#Mean_sea-level_pressure
397+
//
398+
// if you are concerned about accuracy or precision, make sure to pull the
399+
// "sea level pressure"value from a trusted source like NOAA.
394400
void BME280::setReferencePressure(float refPressure)
395401
{
396402
_referencePressure = refPressure;
@@ -406,7 +412,13 @@ float BME280::readFloatAltitudeMeters( void )
406412
{
407413
float heightOutput = 0;
408414

409-
//heightOutput = ((float)-45846.2)*(pow(((float)readFloatPressure()/(float)_referencePressure), 0.190263) - (float)1);
415+
// Getting height from a pressure reading is called the "international barometric height formula".
416+
// The magic value of 44330.77 was adjusted in issue #30.
417+
// There's also some discussion of it here: https://www.sparkfun.com/tutorials/253
418+
// This calculation is NOT designed to work on non-Earthlike planets such as Mars or Venus;
419+
// see NRLMSISE-00. That's why it is the "international" formula, not "interplanetary".
420+
// Sparkfun is not liable for incorrect altitude calculations from this
421+
// code on those planets. Interplanetary selfies are welcome, however.
410422
heightOutput = ((float)-44330.77)*(pow(((float)readFloatPressure()/(float)_referencePressure), 0.190263) - (float)1); //Corrected, see issue 30
411423
return heightOutput;
412424

0 commit comments

Comments
 (0)