Hi guys I connected my new BME280 sensor (Amazon.com: DIYmall BME280 Humidity Temperature Sensor Barometric Pressure Sensor Module with IIC/I2C for Arduino GY-BME280-5V : Electronics) to my Arduino Uno and tested it with Adafruit BME280 test example and I got these readings:
Temperature = 22.85 *C
Pressure = 971.88 hPa
Approx. Altitude = 350.41 m
Humidity = 36.86 %
Temperature in my room is 22C so this is ok. I don't know if humidity is correct or not because I have no way to check it. But pressure I can calculate. Based on my altitude 476m and temperature 22C the pressure should be 959 hPa, but here it is 972 hPa. I tried 4 different libraries and results were similar. Is this a faulty sensor or something else?
The air pressure varies quite a lot, sometimes from hour to hour. Why do you think it should be 959 hPa?
Keep in mind that airports and most weather reports state the air pressure, corrected to sea level. Pilots use the sea level value to set their air-pressure based altimeters.
I used air pressure calculator Air Pressure at Altitude Calculator.
The calculated altitude from the sensor is 350 m but my actual altitude is 476 m so there must be something wrong with it.
26 meters error is not bad for estimated altitude, but that depends on the value you used for the estimated sea level air pressure. What value did you use, and where did you get it?
Most people calibrate their altimeters for the current air pressure, and that has to be done quite frequently. To do so, you calculate the equivalent sea level pressure from the correct altitude and current pressure.
It's actually 126 m error. I used 1013.25 hPa for sea level pressure and I got it from Wikipedia.
I used 1013.25 hPa for sea level pressure and I got it from Wikipedia.
That value is an idealized average and is rarely equal to the actual sea level air pressure. The local air pressure changes there too!
You need to find out what the current sea level air pressure is nearby (your local airport reports it), or calculate it, in order for the estimated barometric altitude to be reasonable.
I couldn't find information about sea level air pressure but I did manage to get air pressure on weather station that is located at 4m elevation and I used that for calculations and now it is quite accurate. Thank you for your help!