sparkfun / Weather_Shield

Barometric pressure, temperature, humidity and light sensing weather shield for Arduino.
https://www.sparkfun.com/
Other
69 stars 67 forks source link

* Changing Pressure reading to pressure_raw #33

Open TJLTM opened 2 years ago

TJLTM commented 2 years ago
jesawyers commented 2 years ago

Here are two functions that I use to take a pressure reading (at altitude) and normalize to sea level pressure. I have tested these functions and they work great.

//********************************************************************************
double calcSeaLevelPress_hPa(double inP_hPa, double inAlt_mtrs) 
{
   double calc = 0.0;

   calc = pow((1 - (inAlt_mtrs / 44330)), 5.255);

   return(inP_hPa / calc);
} 
//********************************************************************************
double calcCorrectedPress_hPa(double inP_hPa, double inP_SL, double inAlt_mtrs, double inDegC) 
{
   double calc = 0.0;

   calc = (0.0065 * inAlt_mtrs) / (inDegC + (0.0065 * inAlt_mtrs) + 273.15);
   calc = 1 - calc;
   return(inP_hPa * pow(calc,-5.257));
}