Posts: 1
Joined: Mon Mar 20, 2017 1:26 pm

Sense HAT pressure readings

Mon Mar 20, 2017 1:52 pm

Hello everyone

Don't know how to fix this issue, but it seems I'm getting incorrect readings for atmosferic pressure from my Sense HAT. At first, values seemed too low but that was just absolute pressure. When I used the equation for sea-level pressure, values always come up 6-7 hPa higher in comparison to weather stations nearby (provided by Weather Underground).

For example, my altitude is approx. 115m above sl and current absolute pressure readings are 1002.3 hPa (approx. 1016.5 hPa sea-level). Weather stations in my surroundings report 1010 hPa.

Am i missing something?

Just to be clear, my Sense HAT is connected with GPIO extension cable and put in separate case. The position is not ideal (approx. 3.5m above ground) but it shouldn't have that much impact on pressure. With extension cable temperature and humidity readings are just fine, only pressure is the issue.

Thank you in advance for your help

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

Re: Sense HAT pressure readings

Fri Mar 31, 2017 3:59 pm

From your post, a difference in altitude of 115m AMSL and 0m AMSL results in a ~10hPa variation.

https://www.sensorsone.com/altitude-pre ... onversion/

Are you sure your surrounding weather stations are at a similar altitude?
Rockets are loud.

Posts: 1
Joined: Mon Oct 16, 2017 4:21 am

Re: Sense HAT pressure readings

Mon Oct 16, 2017 4:31 am

I was going to make my own thread, but figured this one covers exactly the issue I'm having.

My issue is that I'm nearly 800 feet above sea level in my current location and my pi is reporting 29.4 inHg as it's reading, but my davis weather station is reading 29.92 inHg (as well as other local weather stations) -- I am not a python programmer, but I fumble around where I can to make things work here and there. Here's the current code I am using, what is going wrong in this conversion?

Code: Select all

  def get_pressure(self):
        """Gets humidity sensor value and converts pressure from millibars to inHg before posting."""
        return self._sense_hat.get_pressure() * 0.0295300
This code is from: https://github.com/UBayouski/WeatherStation/ (weather_station.py)

Thanks in advance, and I'm sorry if this is seen as a hijack, I promise I mean no harm :)

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

Re: Sense HAT pressure readings

Mon Oct 16, 2017 9:01 pm

Find your local airport code (for example: Heathrow is EGLL, Farnborough is EGLF).
Feed that into http://www.aviationweather.gov/metar?gis=off (check the decoded box) that gives you the local "official" reading from your local national weather service.

From the METAR you have a MSL value

Code: Select all

METAR for:	EGLL (London/Heathrow Intl, --, UK)
Text:	EGLL 162020Z AUTO 23014KT 9999 BKN036 15/09 Q1017
Temperature:	15.0°C ( 59°F)
Dewpoint:	9.0°C ( 48°F) [RH = 67%]
Pressure (altimeter):	30.03 inches Hg (1017.0 mb)
Winds:	from the SW (230 degrees) at 16 MPH (14 knots; 7.2 m/s)
Visibility:	6 or more sm (10+ km)
Ceiling:	3600 feet AGL
Clouds:	broken clouds at 3600 feet AGL
it's the Q value in the RAW METAR data.

Get your elevation using a GPS receiver.

Run this code (you need two values, it returns the third)

Code: Select all

import math
import sys
import argparse

if __name__ == '__main__':
   parser = argparse.ArgumentParser()
   parser.add_argument('-e', '--elevation')
   parser.add_argument('-p', '--pressure')
   parser.add_argument('-m', '--msl')
   args = parser.parse_args()
   if args.elevation is None:
      args.elevation = 112.2  # Value from my GPS for my house
   if args.pressure is None:
      print "Pressure value required"
   if args.msl is None:
      args.msl = 1013.25
   args.pressure = float(args.pressure)
   args.elevation = float(args.elevation)
   args.msl = float(args.msl)

   print "Elev:", args.elevation, "Pressure:", args.pressure, "MSL:", args.msl
   print "Sealevel:",args.pressure/pow(1-(args.elevation/44330.0),5.255)
   print "Elev:",(44330.0*(1-pow(args.pressure/args.msl,1/5.255)))
NOTE: change line# 13 (my default elevation is 112.2m) or you will get invalid output.

[email protected]:/tmp$ ./msl_pressure.py -e 112.2 -p 1004.72
Elev: 112.2 Pressure: 1004.72 MSL: 1013.25
Sealevel: 1018.18970592
Elev: 71.2594761739
[email protected]eaufort:/tmp$ ./msl_pressure.py -m 1018.19 -p 1004.72
Elev: 112.2 Pressure: 1004.72 MSL: 1018.19
Sealevel: 1018.18970592
Elev: 112.20243034
[email protected]:/tmp$

Depending which value(s) (-e & -p or -m & -p) you give it my ugly program returns the missing value (msl or elev). In all cases we're using an absolute (local at altitude) pressure reading from your sensor.
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
Forum Moderator
Forum Moderator
Posts: 1662
Joined: Fri Oct 14, 2011 8:06 pm
Location: The Netherlands
Contact: Twitter

Re: Sense HAT pressure readings

Wed Oct 18, 2017 12:30 pm

Here's the data sheet for the Sense HAT pressure sensor if it's any help: http://www.st.com/web/en/resource/techn ... 066332.pdf

Posts: 36
Joined: Tue Apr 07, 2015 8:03 pm

Re: Sense HAT pressure readings

Mon Oct 23, 2017 6:48 pm

This seems correct to me. Your Sense_Hat is reading the air pressure where you are at; the weather station where your weather station is located is not where you are at and there will be some slight differences.

Here in New York City (Manhattan), the weather below 59th Street can be entirely different from the weather in 125th street (some 2.5 miles away). Often the weathermen on the news will often state "There is rain in midtown, but it is bright and sunny uptown... blah blah blah blah..."

Today (10/23), the air pressure on the news weather report said that it is 28.9 (inHg), but my reading, some 2 miles away from their weather station, showed that it was 30.7 inHg.

Furthering this, the weather stations for the TV and Radio News in NYC are up high on skyscrapers of 50 or more stories (over 500ft) while I am 13 floors up in my home (about 120ft). Consider that Manhattan is only 3ft above sea level, there is a major air pressure difference when one compares height. As is, when riding the elevator in my home building, the air pressure is less in my 13 floor home than it is on the ground floor lobby, making my ears pop when I ride the elevator. In the old days of aviation, knowing that the air pressure was less the higher you go, barometers were also used as altimeters and altitude was semi accurately measured doing it this way.

If the reading is just slightly off, consider it a quirk of the environment and not the Sense_Hat.

Personally, I thought this tread about about something horrible - like when I wrote my modified scrolling_env.py program, I was getting air pressure measurements of over 290 inHg!!! It was a mistake in my conversion... forgot to divide by 10 the final figure. LOL!

Return to “Astro Pi”