@@ -390,7 +390,13 @@ float BME280::readFloatPressure( void )
390
390
391
391
}
392
392
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.
394
400
void BME280::setReferencePressure (float refPressure)
395
401
{
396
402
_referencePressure = refPressure;
@@ -406,7 +412,13 @@ float BME280::readFloatAltitudeMeters( void )
406
412
{
407
413
float heightOutput = 0 ;
408
414
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.
410
422
heightOutput = ((float )-44330.77 )*(pow (((float )readFloatPressure ()/(float )_referencePressure), 0.190263 ) - (float )1 ); // Corrected, see issue 30
411
423
return heightOutput;
412
424
0 commit comments