ludiazv / node-red-contrib-bme280

Node RED BME280/BMP280 sensor node
Other
2 stars 8 forks source link

Incorrect altitude calculation. #5

Open fmuntean opened 4 years ago

fmuntean commented 4 years ago

In order to calculate the altitude the sea level pressure is needed. your algorithm considers the pressure at sea level = 0 which is wrong. Maybe it should be a parameter we can pass in so we can change that.

ludiazv commented 4 years ago

You are right. I will include a parameter with default value 1013.25hPa. You can however quick fix this by removing the 0 parameter in this line manually. https://github.com/ludiazv/node-red-contrib-bme280/blob/5b3199b4144f20bf6fb3a83606328595679836be/bme280.js#L59

ludiazv commented 4 years ago

Updated in master branch the correction

dachshund-digital commented 4 years ago

The correct solution is to query for the correct data from one of the many weather sites, using a geo location site to get the global coordinates then the actual sea level pressure for the given time and location. The 1013.25 value is a common estimate, but it is not truly accurate. When I wrote my python script to support BME280 sensors, I do get the longitude and altitude, and the valid sea level pressure for the actual location of the sensor, thus I get the most accurate altitude measurement. It is a bit of work, but to get the most accurate result, required. This is one of situations where a GPS reading is of benefit, versus having the user provide the location before sensor sampling.

ludiazv commented 4 years ago

GPS or query to external service is beyond the scope of this custom node. Nodered have tons of tools to design your own flows with this logic point out. Now the nodes has a configuration option so you can tune this with your value. But make a modificaiton to allow dynamic change of the value using the trigger input.

dachshund-digital commented 4 years ago

Yes, I just thought it should be noted what the real, true, methodology is to get the altitude correct. Given that you can inject the correct sea-level value, as noted above, into the node, that is reasonable and appropriate.

dachshund-digital commented 4 years ago

Unfortunately, using 1013.25 as an estimated value of pressure at sea level is still not very accurate. I live about 40 m above sea level but the current code, works the elevation out to be over 90 m.

fmuntean commented 4 years ago

Maybe it should be a parameter we can pass in so we can change that.

dachshund-digital commented 4 years ago

It is, you can feed the correct value to the node module. The trick is how you get it, you need the GPS coordinates then query a weather site for the sea level pressure value base on the GPS coordinates, if you do this, this will significantly improve the resulting value from the bme280 chip. For example, using 1013.25 at my location, as the 'estimated' seal level pressure, the bme280 reports my location is about 93m elevation. If I use 1004, which for yesterday was the official sea level pressure at my location, bme280 reports the elevation at about 43m. As validation, the official reported elevation for the city I live in, is 41m. So, 43m is reasonable and comparable to the official value. Whereas, 93m, using the estimated sea level value, is just not even remotely accurate.