• Forums
• Posts
Latest Posts
Active Posts
Recently Visited
Search Results
• Page Extras
• Forum Themes
• AVR Freaks

### Hot!I2C Interfacing XC8 PIC16F877A

Page: << < ..6 Showing page 6 of 6
Author
pcbbc
Super Member
• Total Posts : 1192
• Reward points : 0
• Joined: 2014/03/27 07:04:41
• Location: 0
• Status: offline
Re: I2C Interfacing XC8 PIC16F877A 2019/07/26 03:00:17 (permalink)
+2 (2)
delfindelfin
Well, I am assuming p0 as the standard value of pressure at sea level: 1013.25 hPa

That is not a "standard value".  It's the average for atmospheric pressure at sea level.  If you are expecting it always to be the average value, then your altitude readings are going incorrect, possibly by a substantial amount.

If I take a location near me at the coast, just this week in some very mild weather, the pressure has fluctuated between 1008 hPa to 1018 hPa.  Given 12hPa equates to approximately 100m at low altitudes, that's approximately +/- 40m of error.

But in extreme conditions it could be as high as 1085 hPa or as low as 870 hPa in places, which would be -600m or +1200m.

To calculate a meaningful altitude from atmospheric pressure you need to know either:
a) The current actual pressure at sea level, p0, at a location nearby
b) Your starting altitude (at which point you measure the pressure, and so reverse calculate p0)

What kind of altitudes are you wanting to handle?  If you are close to the earth’s surface (i.e. not in a balloon or plane or hiking to the top of a mountain), and you do not have the above data, you might as well assume 12hPa per 100m.  That is a linear relation, and so easy to do in integer only maths.

Also, if you know your starting altitude you can make a much better estimate using 12hPa/100m as you can remove the error due to current local conditions.
delfindelfin
Super Member
• Total Posts : 374
• Reward points : 0
• Joined: 2017/01/19 12:32:58
• Location: Mexico
• Status: offline
Re: I2C Interfacing XC8 PIC16F877A 2019/07/26 04:04:04 (permalink)
0
Does the atmospheric pressure fluctuates that much also in cities above sea level? .. Let's say I am in a city at 2,100 meters above sea level .. How much can fluctuate? .. I thought I could calculate that altitude figure just by knowing the atmospheric pressure .. But as you mention, is not possible .. That would change a lot of daily things, like for example the temperature at boiling water ..  The sensor says there is 783.89 hP and I am supposed to be at 2,100 meters above sea level
post edited by delfindelfin - 2019/07/26 04:09:07

MPLAB X IDE v5.05
XC8 2.00
pcbbc
Super Member
• Total Posts : 1192
• Reward points : 0
• Joined: 2014/03/27 07:04:41
• Location: 0
• Status: offline
Re: I2C Interfacing XC8 PIC16F877A 2019/07/26 06:35:45 (permalink)
+3 (3)
delfindelfin
Does the atmospheric pressure fluctuate that much also in cities above sea level?

It fluctuates everywhere.  Have you never heard of a barometer or watched a weather forecast?

It's not possible to calculate altitude accurately without knowing an initial condition.  Either a correct p0 or an initial altitude (so you can reverse p0).

I am not a meteorologist, but I would say you will routinely be out by +/-50m.  A lot more in severe weather, which is usually accompanied by larger atmospheric highs and lows.

The sensor says there is 783.89 hP and I am supposed to be at 2,100 meters above sea level

Then pressure at sea level for you today at your location would be 1011.61hPa.  So close to average, but not the standard value.  Try measuring over a number of days, and in different weather conditions, and you will see how it changes.

If you assume p0 is constant at 1013.25:
Just using 12hPa per 100m would give you: 1911 m
Whereas using the real formula gives you: 2113 m

So perhaps at your altitude it is worth using a better approximation to the real formula.  At lower altitudes, less so.  But regardless my point is that using the precise x^(1/5.255) formula is overkill as you cannot achieve any level of accuracy when assuming p0 constant.

Use a GPS if you require an accurate altitude without need for calibration.
Page: << < ..6 Showing page 6 of 6