Author Topic: Using BME280 or similar at altitude and changing temperature  (Read 4863 times)

LukaQ

  • Sr. Member
  • ****
  • Posts: 302
  • Country: si
Using BME280 or similar at altitude and changing temperature
« on: October 18, 2017, 01:16:03 AM »
Hello,

I would like to get input from other users about using ANY pressure measuring sensor at altitude your altitude. Since reference is at sea level, it is very important that you know, your reading will be less the higher you go. Also changes with temperature.

Do anyone compensate for this?

From datasheet:


In Adafruit library I only see that they compensate for each sensors factory values, but nothing for use are environment pressure sensor . Would someone be interested in doing this here with me?
It would be great to have variable for height (if sensor is used at static altitude), read temperature and read pressure + calculate offset based on temperature and height

I guess you would only need to calculate this:


But wait, what is the pressure we read at altitude? do we take sea-level to be constant? I would say it is not

http://keisan.casio.com/exec/system/1224575267
« Last Edit: October 18, 2017, 02:01:28 AM by LukaQ »

LukaQ

  • Sr. Member
  • ****
  • Posts: 302
  • Country: si
Re: Using BME280 or similar at altitude and changing temperature
« Reply #1 on: October 22, 2017, 02:01:51 AM »
No one has any input on this?

LukaQ

  • Sr. Member
  • ****
  • Posts: 302
  • Country: si
Re: Using BME280 or similar at altitude and changing temperature
« Reply #2 on: October 26, 2017, 11:29:40 PM »
Ok, I have no takers

Time to take it to next level I guess.
Felix, if you read, can you show me your pressure graph for a year, that would be great to see!

Anyway, so what's the problem anyway?
In no words, it is this:

If you are using sensor like BM(E/P)280 or similar, you should know, they are calibrated against vacuum. What you get for reading is absolute pressure. That would be that, if you were at sea level.
Probably you are not. If not, you are reading lower pressure, since higher you go, less mass of air is above you = less pressure.
You are missing that right/lower gauge pressure. But you want barometric pressure, so that you can compare your pressure with someone that is below or above you (you reference to as if you were at sea level).
This gauge pressure is almost a constant, but it is not, changes too much. It is dependent on your sensor height above sea level and temperature at sensor.
This is where hypsometric formula comes into play.
(I use hPa, °C and meters for units, so formula is for this units only, for US unit, it's a bit different)
P0 = reference pressure at sea level
h = height in meter above sea level
T = temperature at sensor
P = barometric pressure

Code for arduino looks something like this:
Code: [Select]
  float plusA = mySensorA.readFloatPressure()/100 - mySensorA.readFloatPressure()*pow((1-(0.0065*YOUR_SENSOR_ABOVE_SEA/(mySensorA.readTempC()+0.0065*YOUR_SENSOR_ABOVE_SEA+273.15))),5.2558)/100;
  float plusB = mySensorB.readFloatPressure()/100 - mySensorB.readFloatPressure()*pow((1-(0.0065*YOUR_SENSOR_ABOVE_SEA/(mySensorB.readTempC()+0.0065*YOUR_SENSOR_ABOVE_SEA+273.15))),5.2558)/100;
  float PA = mySensorA.readFloatPressure()/100+plusA;
  float PB = mySensorA.readFloatPressure()/100+plusB;
plusA & plusB are gauge pressure offsets, that you add if you are above sea level, or take away if you are below (probably not many people)
You then add this to your absolute pressure (what you read with sensor) and you get your compensated pressure in PA & PB
« Last Edit: October 26, 2017, 11:58:24 PM by LukaQ »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6867
  • Country: us
    • LowPowerLab
Re: Using BME280 or similar at altitude and changing temperature
« Reply #3 on: October 27, 2017, 04:05:09 PM »
I've honestly not had any interest in atmospheric pressure readings.
And I've never graphed them because they are very constant, between all the sensors, the readings are from 29.02" to 29.04" (inHg).
But thanks for sharing your research. I'm sure it will come handy to others that are interested.

LukaQ

  • Sr. Member
  • ****
  • Posts: 302
  • Country: si
Re: Using BME280 or similar at altitude and changing temperature
« Reply #4 on: October 28, 2017, 08:27:55 AM »
I've honestly not had any interest in atmospheric pressure readings.
And I've never graphed them because they are very constant, between all the sensors, the readings are from 29.02" to 29.04" (inHg).
But thanks for sharing your research. I'm sure it will come handy to others that are interested.
well yes, between sensors they should be, but not when it come to weather. In the past 3/4 year, I have observed many pressure drops, followed by rain, which made in most cases pressure to go up again. It's like personal forecast. Anyway, this I did, because if you look at your local weather news/site/... you see reading that are referenced to sea level, even though there might be big difference in height when you move from sea (if country has it) to mountains area. Absolute pressure will change, but not relative or barometric.

Even mercury readings are dependent on this height (less or more air above it). This in not meant to be compensation between sensors in the same local area.

One example would be, you guys over there have hurricanes and tornados. If you would see your local pressure to drop to 950mBar, that would be bad and as seen from the news, you could have  hurricane Irma on your doorstep.
For reference:
Code: [Select]
Lowest atmospheric pressure (lower is stronger)
Wilma: 882 millibars
Gilbert: 888
Katrina: 902
Irma for reference :914 mbar (hPa); 26.99 inHg
Typical pressure at sea level: 1013
So yes, it is very important how you read your pressure, 914mBar is about 860m above sea level when there is 1013mBar at 0m. Being at 860m and reading absolute pressure does not mean you have hurricane above you, just less air. And then there is temperature, of which is also dependent.

Anyway, I just love this kinda data, to be able to see it

jamacaulay

  • NewMember
  • *
  • Posts: 18
Re: Using BME280 or similar at altitude and changing temperature
« Reply #5 on: November 28, 2018, 06:21:23 PM »
I know I'm a little late to the party, but I found the following formula online that works pretty well for me to convert the reading at your location to sea level pressure.  I define an int called ELEVATION and set it to the altitude in meters where the sensor is located.

SLPressure_mb = (((PressureReading)/pow((1-((double)(ELEVATION))/44330), 5.255))/100.0);

LukaQ

  • Sr. Member
  • ****
  • Posts: 302
  • Country: si
Re: Using BME280 or similar at altitude and changing temperature
« Reply #6 on: December 01, 2018, 01:32:46 PM »
Working in °C and meters and in milibars I have:

Code: [Select]
#define HEIGHT 437
Pressure2 = mySensorB.readFloatPressure()/100;
Pressure2plus = Pressure2 - Pressure2 * pow((1 - (0.0065 * HEIGHT / (Temp4 + 0.0065 * HEIGHT + 273.15))), 5.25588);
Pressure2 = Pressure2 + Pressure2plus;

This was checked over longer period of time against national weather reports and pressure was spot on
And I have a feeling yours is too

moallen

  • NewMember
  • *
  • Posts: 12
Re: Using BME280 or similar at altitude and changing temperature
« Reply #7 on: January 09, 2020, 11:40:54 AM »
Working in °C and meters and in milibars I have:

Code: [Select]
#define HEIGHT 437
Pressure2 = mySensorB.readFloatPressure()/100;
Pressure2plus = Pressure2 - Pressure2 * pow((1 - (0.0065 * HEIGHT / (Temp4 + 0.0065 * HEIGHT + 273.15))), 5.25588);
Pressure2 = Pressure2 + Pressure2plus;

This was checked over longer period of time against national weather reports and pressure was spot on
And I have a feeling yours is too
Just wanted to say I incorporated your formula into my Moteino/BME280 program and now its pressure matches my outside weather station perfectly. Thanks!

LukaQ

  • Sr. Member
  • ****
  • Posts: 302
  • Country: si
Re: Using BME280 or similar at altitude and changing temperature
« Reply #8 on: January 09, 2020, 03:04:50 PM »
Cool, you're welcome

But I will add here, that my BME280 died in about 6 months. This year humidity was brutal all that time
This is not good sensor for constant outdoor use, I will use hs1101 for humidity, for pressure I will use another BME, indoor this time, but do calculation on rPi, with outdoor temperature and indoor pressure

I don't know how other weather stations have solved this

moallen

  • NewMember
  • *
  • Posts: 12
Re: Using BME280 or similar at altitude and changing temperature
« Reply #9 on: January 09, 2020, 04:08:15 PM »
I've tried 3 different humidity sensors (Si7021, HTU21D-F, and AM2315) in my outdoor weather station. The AM2315 lasted the longest, about a year. Just looking at its case, you would've thought it could survive a hurricane. I had my humidity sensors mounted in a solar radiation shield where they are protected from direct rain/snow/etc, but still get air flow. My MCP9808 temp sensor is also mounted there. This is the 3rd winter for it with no problems.

About a year ago I decided to mount my Phidgets temperature/humidity sensor in my attic. That was after I had added 10" of insulation and wanted to monitor things up there. The sensor hangs down about a foot from the peak in middle of the attic. I thought there might be sufficient airflow between gable vents to simulate outdoor humidity. I was surprised to discover it runs very close to actual outdoor humidity. Plus no issues with the outdoor elements anymore. So, that's become my official humidity that I report to WeatherUnderground.

I'm using the Moteino/BME280s inside the house to monitor certain rooms where static is a problem in the winter. I like the idea that I can compare their pressure reading to my outside weather station.

« Last Edit: January 10, 2020, 07:06:08 AM by moallen »

Kilo95

  • Sr. Member
  • ****
  • Posts: 340
  • Country: us
Re: Using BME280 or similar at altitude and changing temperature
« Reply #10 on: January 10, 2020, 10:53:23 AM »
Luka, I'm no where near as programming saavy as everyone else on here. I did notice that it wasn't anywhere close to what the National Weather Service office near me was showing. I figured up the conversion factor of +0.7229 and added that to the (P)ressure line for the Weathershield in metrics.js. My three WeatherShields now read very closely to what the NWS is showing. I'm sure it's not the appropriate scientific way to remedy this

moallen

  • NewMember
  • *
  • Posts: 12
Re: Using BME280 or similar at altitude and changing temperature
« Reply #11 on: January 10, 2020, 11:26:14 AM »
Luka, I'm no where near as programming saavy as everyone else on here. I did notice that it wasn't anywhere close to what the National Weather Service office near me was showing. I figured up the conversion factor of +0.7229 and added that to the (P)ressure line for the Weathershield in metrics.js. My three WeatherShields now read very closely to what the NWS is showing. I'm sure it's not the appropriate scientific way to remedy this
Not counting temperature difference, barometric pressure varies about 1/10" per 100 feet of elevation or a full inch of mercury per 1000 feet. Here where I live it's very hilly. The pressure can be say 29.92" Hg at my house and 30.12 a couple streets away. So, it makes a lot of sense to adjust readings to sea level. There are 7 of us here in our little town with personal weather stations. This morning we were all within 1/100" Hg. Of course, everyone reports at sea level, even though we're 800' to 1,100' elevation.


LukaQ

  • Sr. Member
  • ****
  • Posts: 302
  • Country: si
Re: Using BME280 or similar at altitude and changing temperature
« Reply #12 on: January 13, 2020, 01:27:09 PM »
any idea how profi weather stations measure humidity, something like Davis weather stations?
I think you can buy replacement for $50, but that is not something I would do. Also sounds to me, like they fail at some point.

The 7021 has heater, but that would need to be activated in intervals, probably several times a week. At that time you have no measurements and after that, also no. Sensor would need to cool down completely.

As as far as HS1101 goes, I see nothing that could fail, since you "measure" capacitance and from that freq. which translates to humidity

I am not aware of any digital sensor, that wouldn't fail in the same manner as BME