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: 1688
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: 29746
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

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.

pi@beaufort:/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
pi@beaufort:/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

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.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

User avatar
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 1612
Joined: Fri Oct 14, 2011 8:06 pm
Location: London, United Kingdom
Contact: Website 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

Return to “Astro Pi”

Who is online

Users browsing this forum: No registered users and 2 guests