From a216c8e39f53148debc4f366b6fa05e82e77d4c5 Mon Sep 17 00:00:00 2001 From: "Todd J. Lee" Date: Thu, 23 Jun 2022 11:27:30 -0700 Subject: [PATCH] * Changing Pressure reading to pressure_raw * Adding Pressure Normalization function to Sea Level equiv to output --- .../Weather_Shield_with_GPS_V12.ino | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Firmware/Weather_Shield_with_GPS_V12/Weather_Shield_with_GPS_V12.ino b/Firmware/Weather_Shield_with_GPS_V12/Weather_Shield_with_GPS_V12.ino index 9cfbe38..e7dba35 100644 --- a/Firmware/Weather_Shield_with_GPS_V12/Weather_Shield_with_GPS_V12.ino +++ b/Firmware/Weather_Shield_with_GPS_V12/Weather_Shield_with_GPS_V12.ino @@ -405,6 +405,17 @@ int get_wind_direction() return (-1); // error, disconnected? } +/* Normalize Pressure to Sea Level based on GPS altitude + * See https://www.sensorsone.com/altitude-pressure-units-conversion/ for a chart + * used to derive the eqns below. or https://www.engineeringtoolbox.com/air-altitude-pressure-d_462.html + * linear approximation and interpolation used as it's close enough for sea level to 10,000ft (3048m) +*/ +float BarometricNormalization(float ALT, float Pressure) { + //Imperial Pressure units in inHG + return Pressure + (0.00094797505*ALT+0.1407194); //inHG + //Metric Pressure units in kPa + //return Pressure + (0.10543757571*ALT+0.4668666); //kPa +} //Prints the various variables directly to the port //I don't like the way this function is written but Arduino doesn't support floats under sprintf @@ -437,8 +448,10 @@ void printWeather() Serial.print(rainin, 2); Serial.print(",dailyrainin="); Serial.print(dailyrainin, 2); - Serial.print(",pressure="); + Serial.print(",pressure_raw="); Serial.print(pressure, 2); + Serial.print(",pressure_normalized="); + Serial.print(BarometricNormalization(gps.altitude.feet(),pressure), 2); //can set static Altitude if you wanted instead of basing it on GPS as That will hunt around Serial.print(",batt_lvl="); Serial.print(batt_lvl, 2); Serial.print(",light_lvl="); @@ -466,5 +479,3 @@ void printWeather() Serial.println("#"); } - -