Author Topic: Calibrate Relative Pressure using a Raspberry Pi computer  (Read 4554 times)

0 Members and 1 Guest are viewing this topic.

Offline gszlag

  • Forecaster
  • *****
  • Posts: 427
  • ..have you calibrated your barometer today?
    • Michael's Bay - Manitoulin Island weather
Calibrate Relative Pressure using a Raspberry Pi computer
« on: February 15, 2021, 03:21:03 PM »
Many weather enthusiasts already own a raspberry pi computer to run weewx, Cumulus or other projects. If you can’t afford to buy a Vaisala barometer (approx. $3,000 USD) in order to calibrate your weather station’s barometer, you can probably afford to buy a Bosch BMP390 barometric sensor* (approx. $10 USD or less) for your pi and use the sensor readings to give you a far more accurate Absolute Pressure/Station Pressure reading.

According to the manufacturer: “...sensor’s excellent relative accuracy of ±0.03hPa, which is equivalent to ±25cm difference in altitude.” The data sheet infers that the worst case reading around 25℃ should be ±0.33 hPa.

As a bonus, the Bosch sensor set also includes a temperature sensor that claims an accuracy of ±0.5℃. Bosch seems to be releasing new barometric sensors every year or so. Subsequent releases should be even more accurate.

The Bosch sensor certainly makes things far easier. You no longer have to compare pressure readings with a METAR station or wait for ideal once-a-year weather conditions to compare and calibrate pressure readings. Just enter the sensor’s pressure reading into your personal weather station console as ABS (Absolute Pressure), add the elevation offset for your location and you’ve got the REL (Relative Pressure).

My weather station’s barometric sensor was off by almost 2.0 hPa so having the ability to quickly calibrate or check pressure readings instantly and at any time sure makes things easier.

*NOTE: I bought the Adafruit version of the BMP390 with the Qwiic connectors. The sensor board handles 3.3V or 5V. If you buy a shim and a Qwiic connector cable for just a few bucks, no jumper wires, breadboard or soldering is required.
Ambient Weather WS-2000
Ecowitt GW1000/GW1100
Ecowitt WS68: Anemometer, UV/solar
Ecowitt WH40: Rain gauge
Ecowitt WH57 Lightning sensor
Ecowitt WH32E: Outside T & H sensor
Stratus Rain Gauge (manual)
Raspberry Pi 3B+ (WeeWX/CumulusMX)
Raspberry Pi Zero 2W (WeeWX/MQTT/Belchertown)
---
http://weather.glenns.ca (pwsdashboard - live)
http://weewx.glenns.ca
http://glenns.ca/cumulusmx2/index.htm
---
Uploading to: AWN, ecowitt.net, Weather Underground, PWSweather.com, AWEKAS, Windy.com, WOW

Offline KC5JIM

  • Senior Contributor
  • ****
  • Posts: 229
    • KC5JIM Weather
Re: Calibrate Relative Pressure using a Raspberry Pi computer
« Reply #1 on: March 31, 2022, 05:53:45 PM »
Thanks for the tip. I just received my BMP390 and calibrated.
Ecowitt Wittboy| FOSHKplugin on Pi 4


Offline gszlag

  • Forecaster
  • *****
  • Posts: 427
  • ..have you calibrated your barometer today?
    • Michael's Bay - Manitoulin Island weather
Re: Calibrate Relative Pressure using a Raspberry Pi computer
« Reply #2 on: March 31, 2022, 06:05:32 PM »
Thanks for the tip. I just received my BMP390 and calibrated.
Glad to help!
Just curious, what software program did you use? When I bought the sensor, I couldn't find anything to run it so I tried every BMP388 (Adafruit says they are pretty much the same) program on github. Similar - but not the same(chip register differs by one digit) and finally got it to work. Max sampling rate works best.
I see Bosch has something on github that you can compile. haven't tried it.
Unfortunately getting the pressure readings into WeeWX is beyond my limited skill set. Would be nice though!
Ambient Weather WS-2000
Ecowitt GW1000/GW1100
Ecowitt WS68: Anemometer, UV/solar
Ecowitt WH40: Rain gauge
Ecowitt WH57 Lightning sensor
Ecowitt WH32E: Outside T & H sensor
Stratus Rain Gauge (manual)
Raspberry Pi 3B+ (WeeWX/CumulusMX)
Raspberry Pi Zero 2W (WeeWX/MQTT/Belchertown)
---
http://weather.glenns.ca (pwsdashboard - live)
http://weewx.glenns.ca
http://glenns.ca/cumulusmx2/index.htm
---
Uploading to: AWN, ecowitt.net, Weather Underground, PWSweather.com, AWEKAS, Windy.com, WOW

Offline KC5JIM

  • Senior Contributor
  • ****
  • Posts: 229
    • KC5JIM Weather
Re: Calibrate Relative Pressure using a Raspberry Pi computer
« Reply #3 on: March 31, 2022, 07:26:55 PM »
I used CircuitPython
Ecowitt Wittboy| FOSHKplugin on Pi 4


Offline Fatboy

  • Member
  • *
  • Posts: 17
Re: Calibrate Relative Pressure using a Raspberry Pi computer
« Reply #4 on: October 29, 2022, 02:12:05 AM »
nOOb, just had to say, this was a great find for one with little time.

Offline gszlag

  • Forecaster
  • *****
  • Posts: 427
  • ..have you calibrated your barometer today?
    • Michael's Bay - Manitoulin Island weather
Re: Calibrate Relative Pressure using a Raspberry Pi computer
« Reply #5 on: October 29, 2022, 02:40:33 PM »
nOOb, just had to say, this was a great find for one with little time.
No problem. Glad to help.

Once you get your new sensor working, in order to set up the barometer settings in your display console, some initial reading starts here: https://www.wxforum.net/index.php?topic=43477.msg442840#msg442840
Ambient Weather WS-2000
Ecowitt GW1000/GW1100
Ecowitt WS68: Anemometer, UV/solar
Ecowitt WH40: Rain gauge
Ecowitt WH57 Lightning sensor
Ecowitt WH32E: Outside T & H sensor
Stratus Rain Gauge (manual)
Raspberry Pi 3B+ (WeeWX/CumulusMX)
Raspberry Pi Zero 2W (WeeWX/MQTT/Belchertown)
---
http://weather.glenns.ca (pwsdashboard - live)
http://weewx.glenns.ca
http://glenns.ca/cumulusmx2/index.htm
---
Uploading to: AWN, ecowitt.net, Weather Underground, PWSweather.com, AWEKAS, Windy.com, WOW

Offline watsonm

  • Member
  • *
  • Posts: 38
Re: Calibrate Relative Pressure using a Raspberry Pi computer
« Reply #6 on: October 30, 2022, 05:49:42 AM »
I am using the BMP388 sensor that measures Air pressure (since my console is deceased) and find it pretty accurate having done some tests.  I use some Python code to convert the Absolute Pressure given to Relative pressure using the following formula from the referenced web page.

Quote
   pressureR = float(pressure) + ((float(pressure) * 9.80665 * altitude_amsl)/(287 * (273 + temperature + (altitude_amsl/400))))

See this site for description:

Quote
https://gist.github.com/cubapp/23dd4e91814a995b8ff06f406679abcf


What has suprised me is that quite a few sites have Absolute air pressure greater than Relative pressure. (This is from Ecowitt.net sites)  Ok a few may be below sea level!!   :roll:
Regards Mike

Raspberry Pi 4
Directly connected : BMP388 pressure sensor.  DHT22 For internal Humidity Sensor temp
Wireless connected: 3 Temperature Transmitters(WS2083), WH57  Lightning Sensor, Fine Offset Solar sensor  (stand alone)

Offline gszlag

  • Forecaster
  • *****
  • Posts: 427
  • ..have you calibrated your barometer today?
    • Michael's Bay - Manitoulin Island weather
Re: Calibrate Relative Pressure using a Raspberry Pi computer
« Reply #7 on: October 30, 2022, 09:55:24 AM »
I am using the BMP388 sensor that measures Air pressure (since my console is deceased) and find it pretty accurate having done some tests.  I use some Python code to convert the Absolute Pressure given to Relative pressure using the following formula from the referenced web page.

Quote
   pressureR = float(pressure) + ((float(pressure) * 9.80665 * altitude_amsl)/(287 * (273 + temperature + (altitude_amsl/400))))

See this site for description:

Quote
https://gist.github.com/cubapp/23dd4e91814a995b8ff06f406679abcf

What has suprised me is that quite a few sites have Absolute air pressure greater than Relative pressure. (This is from Ecowitt.net sites)  Ok a few may be below sea level!!   :roll:

Thanks for the link: It looks like a simplified version of some sort of barometric equation. I did not see where or how the author derived this equation.

Have you considered using WeeWX to dynamically calculate SLP and Altimeter?
WeeWX is open source. Code for air pressure can be found on github:
https://github.com/weewx/weewx/blob/master/bin/weewx/uwxutils.py

You could incorporate some of this code into your project or as mentioned, get the BMP388/BMP390 or the new BMP581 to "talk" to WeeWX.
 
Alas, my coding skils are exactly zero but I do know that WeeWX can incorporate all sorts of external sensors. No how-to for the BMP 388/390 as far as I can find and the BMP581 (just came out earlier this year) is only (so far) available for the Arduino platform.

I have a BMP581 on the way and a Raspberry Pico ( supposedly supports the Arduino IDE) so considering my skillset (limited), this will be interesting.

PS. Sorry..missed you comment about Ecowitt.net ABS and REL values. If ABS > REL (they should be the same out-of-the-box). It could be that an attempt was made to calibrate and perhaps they gave up.
« Last Edit: October 30, 2022, 10:10:46 AM by gszlag »
Ambient Weather WS-2000
Ecowitt GW1000/GW1100
Ecowitt WS68: Anemometer, UV/solar
Ecowitt WH40: Rain gauge
Ecowitt WH57 Lightning sensor
Ecowitt WH32E: Outside T & H sensor
Stratus Rain Gauge (manual)
Raspberry Pi 3B+ (WeeWX/CumulusMX)
Raspberry Pi Zero 2W (WeeWX/MQTT/Belchertown)
---
http://weather.glenns.ca (pwsdashboard - live)
http://weewx.glenns.ca
http://glenns.ca/cumulusmx2/index.htm
---
Uploading to: AWN, ecowitt.net, Weather Underground, PWSweather.com, AWEKAS, Windy.com, WOW

Offline Fatboy

  • Member
  • *
  • Posts: 17
Re: Calibrate Relative Pressure using a Raspberry Pi computer
« Reply #8 on: November 10, 2022, 04:16:59 AM »
Thought this would be plug and play w/weewx, save some time. Nope, rabbit hole yet again.

Seems the hardware is GTG.

pi4:~/Adafruit_CircuitPython_BMP3XX/examples $ python bmp3xx_simpletest.py
Pressure: 975.1723  Temperature: 25.36

pi4:~ $ python /usr/share/weewx/weewx/uwxutils.py
PASSED

Next step, clear as mud...

Offline gszlag

  • Forecaster
  • *****
  • Posts: 427
  • ..have you calibrated your barometer today?
    • Michael's Bay - Manitoulin Island weather
Re: Calibrate Relative Pressure using a Raspberry Pi computer
« Reply #9 on: November 10, 2022, 01:34:05 PM »
Thought this would be plug and play w/weewx, save some time. Nope, rabbit hole yet again.

Seems the hardware is GTG.

pi4:~/Adafruit_CircuitPython_BMP3XX/examples $ python bmp3xx_simpletest.py
Pressure: 975.1723  Temperature: 25.36

pi4:~ $ python /usr/share/weewx/weewx/uwxutils.py
PASSED

Next step, clear as mud...

WS-2000 check
SDR check
WeeWX check
Belchertown check
BMP388 check

re: Belchertown skin.. you now have realtime Barometer ( actually barometer could be renamed to MSLP ( Mean Sea Level Pressure) or maybe just SLP.

Might as well add the rest of the pressures from WeeWX to Belchertown:
Altimeter and Pressure (station pressure). Like so.

 [ You are not allowed to view attachments ]

More work for you. Adding the BMP388 pressure reading directly into WeeWX would be nice.
Ambient Weather WS-2000
Ecowitt GW1000/GW1100
Ecowitt WS68: Anemometer, UV/solar
Ecowitt WH40: Rain gauge
Ecowitt WH57 Lightning sensor
Ecowitt WH32E: Outside T & H sensor
Stratus Rain Gauge (manual)
Raspberry Pi 3B+ (WeeWX/CumulusMX)
Raspberry Pi Zero 2W (WeeWX/MQTT/Belchertown)
---
http://weather.glenns.ca (pwsdashboard - live)
http://weewx.glenns.ca
http://glenns.ca/cumulusmx2/index.htm
---
Uploading to: AWN, ecowitt.net, Weather Underground, PWSweather.com, AWEKAS, Windy.com, WOW

Offline Fatboy

  • Member
  • *
  • Posts: 17
Re: Calibrate Relative Pressure using a Raspberry Pi computer
« Reply #10 on: November 11, 2022, 05:03:37 PM »
I am using the BMP388 sensor that measures Air pressure (since my console is deceased) and find it pretty accurate having done some tests.  I use some Python code to convert the Absolute Pressure given to Relative pressure using the following formula from the referenced web page.

Quote
   pressureR = float(pressure) + ((float(pressure) * 9.80665 * altitude_amsl)/(287 * (273 + temperature + (altitude_amsl/400))))

See this site for description:

Quote
https://gist.github.com/cubapp/23dd4e91814a995b8ff06f406679abcf


What has suprised me is that quite a few sites have Absolute air pressure greater than Relative pressure. (This is from Ecowitt.net sites)  Ok a few may be below sea level!!   :roll:

bmp.pressure, bmp.temperature, a2ts

978.24 26.99 1016.58

Does that seem right for 350M ASL?

So much testing, formatting, etc, etc, etc fun never ends.

Offline Fatboy

  • Member
  • *
  • Posts: 17
Re: Calibrate Relative Pressure using a Raspberry Pi computer
« Reply #11 on: November 11, 2022, 06:23:15 PM »
BMP-pressure: 979.63     BMP-temp: 26.63     A2TS: 1017.81

Offline Fatboy

  • Member
  • *
  • Posts: 17
Re: Calibrate Relative Pressure using a Raspberry Pi computer
« Reply #12 on: November 11, 2022, 06:34:02 PM »
Looks right via local-ish metar.

This work thing is always in the way  :-|

Offline watsonm

  • Member
  • *
  • Posts: 38
Re: Calibrate Relative Pressure using a Raspberry Pi computer
« Reply #13 on: November 12, 2022, 04:00:14 AM »
Hi, sorry I missed your post.

All I can tell you is my experience.  I use that formula and regulary compare it to the Windy.com website and my station seems to track it quite well

Quote
https://www.windy.com/?50.717,-2.434,5,i:pressure

Regards Mike

Raspberry Pi 4
Directly connected : BMP388 pressure sensor.  DHT22 For internal Humidity Sensor temp
Wireless connected: 3 Temperature Transmitters(WS2083), WH57  Lightning Sensor, Fine Offset Solar sensor  (stand alone)

Offline gszlag

  • Forecaster
  • *****
  • Posts: 427
  • ..have you calibrated your barometer today?
    • Michael's Bay - Manitoulin Island weather
Re: Calibrate Relative Pressure using a Raspberry Pi computer
« Reply #14 on: November 12, 2022, 07:41:53 AM »
I am using the BMP388 sensor that measures Air pressure (since my console is deceased) and find it pretty accurate having done some tests.  I use some Python code to convert the Absolute Pressure given to Relative pressure using the following formula from the referenced web page.

Quote
   pressureR = float(pressure) + ((float(pressure) * 9.80665 * altitude_amsl)/(287 * (273 + temperature + (altitude_amsl/400))))

See this site for description:

Quote
https://gist.github.com/cubapp/23dd4e91814a995b8ff06f406679abcf


What has suprised me is that quite a few sites have Absolute air pressure greater than Relative pressure. (This is from Ecowitt.net sites)  Ok a few may be below sea level!!   :roll:

bmp.pressure, bmp.temperature, a2ts

978.24 26.99 1016.58

Does that seem right for 350M ASL?

So much testing, formatting, etc, etc, etc fun never ends.

At 350m ASL your Altimeter reading will always be 41.3 hPa higher than the current BMP pressure so you are out about 3 hPa.(too low).

To correct for that, you will have to add a correction (we call that an offset) in order to match the Altimeter reading at a close-by airport. You will have to add 3 hPa to compensate.

Note that this is not necessarily an error correction - you are correcting for elevation. Mentally, you are adding pressure as you are approaching sea level - air pressure is higher at sea level than it is at say, the top of Mt. Everest.

Basically, when you add pressure to correct for elevation above sea level, you are pretending that your BMP388 is located exactly at mean sea level elevation ( 0 meters) even though it is currently sitting at 350m.

Take a look at this table in order to visualize the concept:

 [ You are not allowed to view attachments ]

The above table is a theoretical calculation (an approximation of Altimeter) under what's called "standard atmosphere" conditions.

Calculating SLP ( on a METAR report) is a far more complex calculation as it not only corrects for your elevation but temperature too. To calculate SLP you would need to know your 12 hour average temperature or minimally, your current temperature. WeeWX does all these pressure calculations dynamically in real time. In WeeWX all you have to do is put in your BMP388 elevation ASL and you are done assuming that your BMP388 is perfectly calibrated and accurate. But that is another topic.

Update: I just realized you are using Mike's algorithm after wondering what the heck is A2TS? That's what the dev named his github script.

The algorithm uses temperature as an input variable so it must be calculating SLP rather than Altimeter. Altimeter ignores temperature.

If QNH/Altimeter < QFF/SLP) then outside temperatures are lower than your ISA temp of 12.7C for your elevation of 350m. However, a 3 hPa difference seems to be a pretty big difference this time of year. Your temps would have to be  about -8C?

For some comparisons, use this calculator and see what you get:
https://www.starpath.com/barometers/baro_cal.php. Note: Make sure your elevation is as accurate as possible.

Bottom line: Verify the accuracy of your barometric sensor by matching your airport's METAR Altimeter(setting) reading first and then use WeeWX to calculate "Barometer/MSLP" on the default Seasons skin or use another algorithm of your own choosing.
« Last Edit: November 12, 2022, 01:21:22 PM by gszlag »
Ambient Weather WS-2000
Ecowitt GW1000/GW1100
Ecowitt WS68: Anemometer, UV/solar
Ecowitt WH40: Rain gauge
Ecowitt WH57 Lightning sensor
Ecowitt WH32E: Outside T & H sensor
Stratus Rain Gauge (manual)
Raspberry Pi 3B+ (WeeWX/CumulusMX)
Raspberry Pi Zero 2W (WeeWX/MQTT/Belchertown)
---
http://weather.glenns.ca (pwsdashboard - live)
http://weewx.glenns.ca
http://glenns.ca/cumulusmx2/index.htm
---
Uploading to: AWN, ecowitt.net, Weather Underground, PWSweather.com, AWEKAS, Windy.com, WOW

Offline gszlag

  • Forecaster
  • *****
  • Posts: 427
  • ..have you calibrated your barometer today?
    • Michael's Bay - Manitoulin Island weather
Re: Calibrate Relative Pressure using a Raspberry Pi computer
« Reply #15 on: November 12, 2022, 08:37:33 AM »
Hi, sorry I missed your post.

All I can tell you is my experience.  I use that formula and regulary compare it to the Windy.com website and my station seems to track it quite well

Quote
https://www.windy.com/?50.717,-2.434,5,i:pressure

Since you are at a low elevation - temperature does not matter much..may be at most 0.6 hPa at temperature extremes.

I took a look at METAR EGHH. It reports QNH. I am pretty sure the MET Office reports SLP with a lot more accuracy than QNH so you can compare the two..

Your ISA temperature at 103m is about 14C so at 14C QNH = QFF (Windy's isobars) At low elevations, a simple additive constant of 12.3 hPa would be even simpler than the github formula. In other words, add 12.3 to your current live station pressure reading. But if your formula is working for you, keep it.

Keep an eye on it on the coldest day of the year and see how it goes.
Ambient Weather WS-2000
Ecowitt GW1000/GW1100
Ecowitt WS68: Anemometer, UV/solar
Ecowitt WH40: Rain gauge
Ecowitt WH57 Lightning sensor
Ecowitt WH32E: Outside T & H sensor
Stratus Rain Gauge (manual)
Raspberry Pi 3B+ (WeeWX/CumulusMX)
Raspberry Pi Zero 2W (WeeWX/MQTT/Belchertown)
---
http://weather.glenns.ca (pwsdashboard - live)
http://weewx.glenns.ca
http://glenns.ca/cumulusmx2/index.htm
---
Uploading to: AWN, ecowitt.net, Weather Underground, PWSweather.com, AWEKAS, Windy.com, WOW