0

Understanding MPL3115A2 Readings
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Understanding MPL3115A2 Readings

by teranz on Fri Apr 26, 2019 10:25 am

Hi:

I am using a PIC16F18346 MPU to interface to the MPL3115A2 - I2C Barometric Pressure/Altitude/Temperature breakout board. I can get the data via I2C but I am not sure about what I am reading. For the pressure measurement I read the data as Pascals, do the manufacturer`s scaling then divide my 100 to get hPa. I am currently reading about 967.3 kPa and also display that as 28.56 inHg. However, the National Weather Service for my area shows the pressures as 29.74 inHg (1006.4 mb). My readings correspond closely with what I see on my smart phone, but why would the weather service be so different?

Thanks- Tom
Last edited by teranz on Sun Apr 28, 2019 9:50 am, edited 1 time in total.

teranz
 
Posts: 12
Joined: Thu Apr 11, 2019 10:30 pm

Re: Understanding MPL115A2 Readings

by adafruit_support_bill on Fri Apr 26, 2019 10:30 am

What you are reading is the actual pressure at your location. What the weather service reports is normalized to sea level - since it is used by airplane pilots to calibrate their altitude sensors.

https://www.ambientweather.com/sebaprco.html

adafruit_support_bill
 
Posts: 73190
Joined: Sat Feb 07, 2009 10:11 am

Re: Understanding MPL115A2 Readings

by teranz on Fri Apr 26, 2019 11:16 am

OK, that website helps.

I am using the barometric input for altitude corrections and that does allow a much closer altitude calculation for my location.

Is the MPL3115A2 pressure reading in Pascals a linear measurement? Could I add an offset to the current readings so the value would match the weather station? If Yes, would weather station readings be tracked accurately? Linearly?

Thanks- Tom

teranz
 
Posts: 12
Joined: Thu Apr 11, 2019 10:30 pm

Re: Understanding MPL115A2 Readings

by adafruit_support_bill on Fri Apr 26, 2019 11:29 am

It is a little more complex than that: https://en.wikipedia.org/wiki/Barometric_formula

This thread has some code that will do the conversion:
https://www.meteocercal.info/forum/Thre ... ith-BMP280

Code: Select all | TOGGLE FULL SIZE
SLpressure_mB = (((pressure)/pow((1-((float)(ELEVATION))/44330), 5.255))/100.0)

adafruit_support_bill
 
Posts: 73190
Joined: Sat Feb 07, 2009 10:11 am

Re: Understanding MPL115A2 Readings

by teranz on Fri Apr 26, 2019 11:58 am

Thanks, these replies are just what I needed!
Tom

teranz
 
Posts: 12
Joined: Thu Apr 11, 2019 10:30 pm

Re: Understanding MPL115A2 Readings

by teranz on Sat Apr 27, 2019 6:03 pm

OK... One more question please...

Now that I have the pressure values loaded to the chip for the adjusted barometric pressure (sea level, I`m at about 1100 ft) my local altitude reading is closer, but it also varies. Is this due to my local sea level pressure changing with weather patterns, and I would constantly be needing to adjust the Bar_in values to get a constant accurate altitude?

teranz
 
Posts: 12
Joined: Thu Apr 11, 2019 10:30 pm

Re: Understanding MPL115A2 Readings

by adafruit_support_bill on Sat Apr 27, 2019 6:48 pm

If your sensor is stationary, then the altitude is constant. What is subject to change is the measured atmospheric pressure which will vary with the weather. To get a pressure reading that tracks the local weather station, you need to apply the same conversion to your measured pressure.

adafruit_support_bill
 
Posts: 73190
Joined: Sat Feb 07, 2009 10:11 am

Re: Understanding MPL115A2 Readings

by teranz on Sat Apr 27, 2019 8:42 pm

I expect my local pressure to change, and yes the altitude is constant. But I want to see the altitude reported from the sensor to be constant. Would I not need to change the bar_in values to correct the reported altitude to compensate for the pressure changes?

Sorry, this pressure/altitude data is new to me-

teranz
 
Posts: 12
Joined: Thu Apr 11, 2019 10:30 pm

Re: Understanding MPL115A2 Readings

by adafruit_support_bill on Sun Apr 28, 2019 5:47 am

It is not clear what you mean by 'bar_in'. Is that something in the code you are using?

adafruit_support_bill
 
Posts: 73190
Joined: Sat Feb 07, 2009 10:11 am

Re: Understanding MPL115A2 Readings

by teranz on Sun Apr 28, 2019 8:46 am

Sorry, Bar_In is the register in the MPL115A2 used to set the localized barometric pressure sea level adjustment. I`m at about 1100 feet elevation, I place the altitude adjusted sea level pressure value there so when the actual sea level pressure is 1013.24 kPa my altitude will be correct.

teranz
 
Posts: 12
Joined: Thu Apr 11, 2019 10:30 pm

Re: Understanding MPL115A2 Readings

by adafruit_support_bill on Sun Apr 28, 2019 9:03 am

I'm not seeing that register in the datasheet: https://cdn-shop.adafruit.com/datasheets/MPL115A2.pdf
I see coefficients to compensate for temperature and linearity. But I don't see a bar_in register.

adafruit_support_bill
 
Posts: 73190
Joined: Sat Feb 07, 2009 10:11 am

Re: Understanding MPL115A2 Readings

by teranz on Sun Apr 28, 2019 9:06 am

Page 27, BAR_IN_MSB, BAR_IN_LSB, (0x14, 0x15).

I MESSED UP, it is a MPL3115A2, sorry, my bad.

teranz
 
Posts: 12
Joined: Thu Apr 11, 2019 10:30 pm

Re: Understanding MPL115A2 Readings

by adafruit_support_bill on Sun Apr 28, 2019 9:19 am

OK. For that sensor, you can adjust for local pressure for altitude calculations. The BAR_IN register is the right way to do that. You would take the sea-level adjusted pressure in kPa ad divide by 2.

7.8.1 BAR_IN_MSB, BAR_IN_LSB (0x14, 0x15)
Barometric input for altitude calculations. Input is equivalent sea level pressure for measurement location.
Value is input in 2 Pa units.

Units are input as unsigned 16-bit integers. The default value is 101,326 Pa. The default value can be changed by writing to
this register

adafruit_support_bill
 
Posts: 73190
Joined: Sat Feb 07, 2009 10:11 am

Re: Understanding MPL115A2 Readings

by teranz on Sun Apr 28, 2019 9:23 am

But, as the local pressure changes, do I not need to track that and update Bar_In so the calculated altitude will remain accurate?

teranz
 
Posts: 12
Joined: Thu Apr 11, 2019 10:30 pm

Re: Understanding MPL3115A2 Readings

by teranz on Sun Apr 28, 2019 10:47 am

I have been running some tests with the help of this website:
https://www.mide.com/pages/interplaneta ... calculator
Seems to back up my thinking about correcting the altitude calculation using updated Bar_In values.

Using the following data gives expected results...

Current Pressure at Sea Level: 101466 Pa (from Weather Service for my location)
Default Temperature: 21 deg C (my location)
Local Air Pressure at Altitude: 97550 Pa (my Location, adjusted to sea level pressure = 101326 Pa)

Calculated Altitude: 1104.78 Feet Elevation

teranz
 
Posts: 12
Joined: Thu Apr 11, 2019 10:30 pm

Please be positive and constructive with your questions and comments.