User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

[SOLVED] BMP085 - how to set altitude?

Thu Jan 02, 2014 9:17 pm

I connected and did setup like adafruit says
but that example.py doesnt work well without altitude set

Can anyone show me how to set absolute variable of altitude?
Last edited by Onira on Sun Jan 05, 2014 12:57 pm, edited 1 time in total.
Cogito ergo sum

User avatar
DougieLawson
Posts: 35581
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: BMP085 - how to set altitude?

Thu Jan 02, 2014 9:43 pm

With any barometric altimeter you can only read pressure OR altitude you can't read both. The pressure reading assumes you're at mean sea level (MSL)

If you know an accurate MSL (aka QNH) pressure value, you can fine tune your altitude value. If your location is above sea level then you need to fine tune both values. The standard is to base everything off 1013.25 hPA. But if your local MSL pressure is higher or lower than that then your altitude will be wrong.

Above 18,000ft everyone sets their altimeter to 1013.25 as that stops them colliding with other aircraft who should be maintaining 1,000ft vertical separation if they're flying in the opposite direction to you.

http://www.stolaf.edu/people/hansonr/so ... timetr.htm has an explanation.
http://en.wikipedia.org/wiki/Atmospheric_pressure has the formula for how pressure changes as you go up from sea level.

An end-user GPS receiver is good to about 10m resolution for Z value so can be used to give a reasonable approximation of your altitude. Local trig points are well defined and accurately measured so if you can take your RPi up a mountain with a trig point you can accurately calibrate it. The contour lines on a 1:25,000 Ordnance Survey sheet are also relatively accurate but to use those relies on having an accurate X & Y location. Again with end-user GPS you can be off by 10m in either X or Y or both.

Remember the pressure changes every day with the weather so you have to re-calibrate your altimeter every time the pressure changes.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

Re: BMP085 - how to set altitude?

Fri Jan 03, 2014 5:55 am

anyway, if I don't care about the altitude, is the pressure measured by BMP085 correct[b?[/b]
If you know an accurate MSL (aka QNH) pressure value, you can fine tune your altitude value.
I red that I can but I don't know how to do this...
Cogito ergo sum

User avatar
DougieLawson
Posts: 35581
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: BMP085 - how to set altitude?

Fri Jan 03, 2014 8:59 pm

Do you know roughly how high your position is above sea level?
What results do you get from your BMP085? When you run:

Code: Select all

#!/usr/bin/python
from Adafruit_BMP085 import BMP085
bmp = BMP085(0x77,3)
temp = bmp.readTemperature()
pressure = bmp.readPressure()
altitude = bmp.readAltitude()
print "Temperature: %.2f C" % temp
print "Pressure: %.2f hPa" % (pressure / 100.0)
print "Altitude: %.2f" % altitude
What pressure did they give on your local weather forecast?
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

ric_rpi
Posts: 206
Joined: Thu Jul 11, 2013 2:33 pm
Location: Bedford, UK

Re: BMP085 - how to set altitude?

Fri Jan 03, 2014 9:18 pm

DougieLawson wrote:An end-user GPS receiver is good to about 10m resolution for Z value so can be used to give a reasonable approximation of your altitude. Local trig points are well defined and accurately measured so if you can take your RPi up a mountain with a trig point you can accurately calibrate it. The contour lines on a 1:25,000 Ordnance Survey sheet are also relatively accurate but to use those relies on having an accurate X & Y location. Again with end-user GPS you can be off by 10m in either X or Y or both.
GPS handheld devices are not very accurate in height. For starters the ellipsoid/geoid correction can be out by tens of meters, even with factoring WGS84. Most UAVs use Laser Altimeters to get round this issue.

Ordnance Survey data will be more accurate or you could try looking up the local pressue from the MET office if you don't fancy a walk up a mountain to a trig point.

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2035
Joined: Thu Jul 11, 2013 2:37 pm

Re: BMP085 - how to set altitude?

Fri Jan 03, 2014 9:44 pm

ric_rpi wrote:
DougieLawson wrote:An end-user GPS receiver is good to about 10m resolution for Z value so can be used to give a reasonable approximation of your altitude. Local trig points are well defined and accurately measured so if you can take your RPi up a mountain with a trig point you can accurately calibrate it. The contour lines on a 1:25,000 Ordnance Survey sheet are also relatively accurate but to use those relies on having an accurate X & Y location. Again with end-user GPS you can be off by 10m in either X or Y or both.
GPS handheld devices are not very accurate in height. For starters the ellipsoid/geoid correction can be out by tens of meters, even with factoring WGS84. Most UAVs use Laser Altimeters to get round this issue.

Ordnance Survey data will be more accurate or you could try looking up the local pressue from the MET office if you don't fancy a walk up a mountain to a trig point.
When I plugged my SiRF GPS receiver into a Pi (and subsequently fixed the Pi to stop it crashing so much) I got a pretty good result from the lat/long reports (to within 5m or so). Altitude was a bit more sketchy but hovered around the correct value of 31 metres AMSL (57 degrees N). The variance wasn't too huge after a settling time and with 5 satellites visible.
Rockets are loud.
https://astro-pi.org

User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 12:45 pm

google says the altitude in my place is 76,214m
Cogito ergo sum

User avatar
DougieLawson
Posts: 35581
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 12:50 pm

Onira wrote:
google says the altitude in my place is 76,214m
And what does the output from your BMP085 say today? How close to 76.214m is it? How close to 1013.25hPA is your pressure reading?
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 1:01 pm

Code: Select all

 $ python Adafruit_BMP085_example.py
Temperature: 23.60 C
Pressure:    1002.92 hPa
Altitude:    85.35
Cogito ergo sum

User avatar
DougieLawson
Posts: 35581
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 2:26 pm

So you're off by 9.136 metres (compared to Google Earth).

Your pressure at 76.214m is 1002.92hPa
So the pressure at MSL is approx 1011hPa

So if we change the python code to:
altitude = bmp.readAltitude(101100)

the altitude (today) should come out closer to Google's estimate.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 3:24 pm

Now, I get:

Code: Select all

 $ python Adafruit_BMP085_example.py
Temperature: 23.60 C
Pressure:    1002.33 hPa
Altitude:    72.76
so... do I have to calculate and set the altitude every day?
Cogito ergo sum

User avatar
DougieLawson
Posts: 35581
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 4:36 pm

Onira wrote:Now, I get:

Code: Select all

 $ python Adafruit_BMP085_example.py
Temperature: 23.60 C
Pressure:    1002.33 hPa
Altitude:    72.76
so... do I have to calculate and set the altitude every day?
Yes.

Your result is about 4m off so you should try 101200 and I think you'll get closer.

Every day when the pressure changes you have to re-set your altimeter.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 4:40 pm

thank You for helping me
now I get:

Code: Select all

$ python Adafruit_BMP085_example.py
Temperature: 23.90 C
Pressure:    1000.85 hPa
Altitude:    93.11
Cogito ergo sum

User avatar
DougieLawson
Posts: 35581
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 4:47 pm

Onira wrote:thank You for helping me
now I get:

Code: Select all

$ python Adafruit_BMP085_example.py
Temperature: 23.90 C
Pressure:    1000.85 hPa
Altitude:    93.11
Your local pressure has changed from earlier.
Go the other way.
100900 or 101000.

Modify that value in small increments until your displayed altitude gets close to your datum.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 4:51 pm

Code: Select all

$ python Adafruit_BMP085_example.py
Temperature: 23.90 C
Pressure:    1000.70 hPa
Altitude:    77.30
:D
Cogito ergo sum

User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 6:14 pm

so all I need is to know the current local pressure to set the MSL pressure?
Cogito ergo sum

User avatar
DougieLawson
Posts: 35581
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 6:49 pm

Onira wrote:so all I need is to know the current local pressure to set the MSL pressure?
To get altitude you need MSL.

That's true for a small change in altitude where the formula for pressure vs altitude is almost a straight line.

If MSL is 1013.25 your pressure will be approx 1004.00.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 6:54 pm

knowing my local pressure I can count and set the MSL or is MSL an absolute value for my place?
Last edited by Onira on Sat Jan 04, 2014 7:25 pm, edited 2 times in total.
Cogito ergo sum

User avatar
DougieLawson
Posts: 35581
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 7:22 pm

Onira wrote:knowing my local pressure I can count and set the MSL or is MSL an absolute value for my place?
Pressure at Mean Sea Level is constantly varying.
Your local pressures is constantly varying.
The ratio between the two is constant for all sensible purposes.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 7:26 pm

Code: Select all

 $ python Adafruit_BMP085_example.py
Temperature: 24.30 C
Pressure:    998.17 hPa
Altitude:    99.79
so if the altitude changed, how often do I need to set the MSL pressure in code?
Cogito ergo sum

User avatar
DougieLawson
Posts: 35581
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 7:34 pm

Onira wrote:

Code: Select all

 $ python Adafruit_BMP085_example.py
Temperature: 24.30 C
Pressure:    998.17 hPa
Altitude:    99.79
so if the altitude changed, how often do I need to set the MSL pressure in code?
Every time before you intend to move your sensing equipment from its current position.

So unless you live in an area with incredible seismic activity that's never.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 7:37 pm

my RPi is placed in my home in my room on the desk and I didn't move it since 31st dec so why is this all changing?
I thought it will be constant or very close to the constant...
Cogito ergo sum

User avatar
DougieLawson
Posts: 35581
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 7:40 pm

http://www.raspberrypi.org/forum/viewto ... 04#p479204

You can read pressure or altitude NOT both.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 7:48 pm

makes no sense to me, sorry :(
Cogito ergo sum

User avatar
DougieLawson
Posts: 35581
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: BMP085 - how to set altitude?

Sat Jan 04, 2014 9:40 pm

Onira wrote:makes no sense to me, sorry :(
What thing is constant?

Here's a clue: altitude.


What thing is variable, never constant?

Here's a clue: air pressure at both your altitude and at mean sea level. It's called means sea level because it compensates for the tides.


What does your BMP085 measure?


Here's a clue: ambient temp & barometric pressure.


Why is reading altitude such a puzzle?

It's fixed, but the pressure reading varies with metro conditions, so you have to compensate for that variation on every reading.


If altitude is unknown you can't determine it from pressure alone. If altitude is known you can calculate pressure at MSL.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Return to “Troubleshooting”