meshtastic / firmware

Meshtastic device firmware
https://meshtastic.org
GNU General Public License v3.0
2.98k stars 714 forks source link

[Feature Request]: Report altitude from pressure #3983

Closed Adrelien closed 1 month ago

Adrelien commented 1 month ago

Platform

ESP32

Description

I have noticed that altitude is not accurate at all from GPS modules like neo 6m. I think the bme280 pressure sensor is far more reliable. https://pilotinstitute.com/pressure-altitude-explained/

todd-herbert commented 1 month ago

Does this vary depending on the weather? I know aircraft often need to get weather information from the local airport to get their local pressure and calibrate the altimeter.

Adrelien commented 1 month ago

Well the BME280 does have a temperature sensor as well.

todd-herbert commented 1 month ago

Is it that simple? I'm all for it if it's possible. It probably doesn't have to be super accurate either to beat some of the GPS altitudes I've seen.

Adrelien commented 1 month ago

I am not a math guy but quick question to chatgpt The hypsometric formula is used to calculate the altitude (height above sea level) based on the atmospheric pressure and temperature. This formula is derived from the barometric formula and the ideal gas law. The hypsometric equation can be expressed as: image Where:

ℎ h is the altitude (height above sea level). 𝑇 𝑚 T m ​ is the mean temperature of the air layer between the two pressure levels in Kelvin. 𝐿 L is the temperature lapse rate (the rate at which temperature decreases with an increase in altitude). For the troposphere, 𝐿 ≈ 0.0065   K/m L≈0.0065K/m. 𝑃 P is the atmospheric pressure at the altitude ℎ h. 𝑃 0 P 0 ​ is the reference pressure at sea level (usually 101325   Pa 101325Pa or 1013.25   hPa 1013.25hPa). 𝑅 R is the universal gas constant ( 𝑅 ≈ 8.314462618   J/(mol \cdotp K) R≈8.314462618J/(mol\cdotpK)). 𝑔 g is the acceleration due to gravity ( 𝑔 ≈ 9.80665   m/s 2 g≈9.80665m/s 2 ). 𝑀 M is the molar mass of Earth's air ( 𝑀 ≈ 0.0289644   kg/mol M≈0.0289644kg/mol). In many practical applications, a simplified form of the hypsometric formula is used, assuming a standard temperature lapse rate and mean temperature: image image

Jorropo commented 1 month ago

Planes uses barometers as differential measurements more than absolute ones. For example when flying at FL310 you will be 1000ft above someone flying at FL300, even tho in reality you might be flying at 25000ft and 24000ft, it's more convenient to use a wrong but standard sea level pressure as separation to avoid mid air collisions is what matters. It also help to normalize flying performance as lower pressures at identical altitude very directly correlate to identical pressure at higher altitude.

In situations where flying into terrain is likely* they will use a local reference (usually an airport which have an automated weather station), the airport knows it's local temperature, local barometric pressure, and it's altitude, computes the equivalent sea level pressure and publish this to pilots.

*this is given to you by controllers and automated robots as TA and TL, which are Transition Altitude and Transition Level respectively, theses are altitude and level where bellow you use local corrected pressure and above you use standard 1013.25hpa. The interesting thing to note is that there are two numbers not one, usually 1000ft apart, this create a 1000ft buffer so planes on different references don't fly into each other.


All of this to say:

Can you get altitude from pressure ?

Yes however it requires knowing the pressure and altitude at some nearby site.

You could imagine a FIXED_POSITION node reporting pressure and altitude, and some nearby node comparing the barometric value to give an altitude.

Can you get altitude without a reference ?

No. But you can assume the sea level pressure is 1013.25hPa. You can imagine embedding a database of average sea level pressure based on the location, time in the day and time of year.

Will assuming the reference be accurate ?

If you want to get an idea, go to https://metar-taf.com/ then look for hPa measurements, then as a rule of thumb for every hPa above or bellow 1013.25 you would incorrectly report the node 30ft above or bellow where it really is. I havn't tried using a database to correct for local tendencies, I guess it would be better as the sun and yearly weather patterns are significant contributors. This approach becomes worst overtime as climate change make the climate less predictable and does not match historical data as well.

Can a temperature sensor help ?

Yes but not that much, the temperature sensor help correct assumptions in how pressure scales as you climb or descent it doesn't let you recover a reference.