Measuring atmospheric pressure simplified

matherp

Senior Member
There was a long thread about this earlier this year but a failure of my commercial weather station prompted looking at it again.

The easiest sensor to use is the MPX4115 but this has the disadvantage that standard atmospheric pressures will create an output in the range 3.8-4.3 volts. This means that with a 10 bit ADC accuracy will be in the 2-4mb range.

Using the solver in excel I calculated that if the ADC could be fed a negative reference voltage of 3.848 volts then accuracy would be increased to better than 1 mb and also that the calculation of pressure would be trivial (1mb change = exactly 4 ADC counts)

Only the 18M2, 28X2, and 40X2 have this negative reference capability so an 18M2 was used.

Code is:
Code:
#picaxe 18m2
' Measure pressure using a MPX4115
' Use a reference voltage of 3.848 volts on pin C.2 to give 4 ADC counts per millibar
symbol Heightadjust=33 'Pressure effect of local barometer height above sea level in MB*4
symbol ADCadjust = 3843 ' Equivalent pressure for 3.848 volts scaled by 4 (960.667mb)
symbol pressure=w0
adcconfig %100 ' Set C.2 as the negative reference for the ADC
do
	pause 1000
	readadc10 b.3,pressure
	pressure=pressure+ADCadjust+Heightadjust
	pressure=pressure/4
	debug
loop
As has been previously discussed the output of the MPX4115 is noisy so it needs decoupling and the output filtering as per the datasheet.
Hope this is of use, I like the fact that using a specific reference voltage not only increases accuracy but makes the math trivial compared to the sensors standard calculation: Vout = Vdd * (0.009 * pressure in kPa -0.095). The 3.848V reference is just set using a 20 turn trimmer pot.
 

kranenborg

Senior Member
I note that in recent years a number of pressure sensors have become available that communicate directly via SPI or I2C, and Sparkfun has a number of them available on breakout boards (in particular the BMP085 sensor is interesting (I2C) and not very expensive, the SCP1000 is the one I have but is now obsolete).

/Jurjen
 

Texy

Senior Member
Interesting, because I am again looking at my altimeter project at the moment, although I,m using opamps and a 12-bit ADC to improve resolution. Could you please show how you calculated the heightadjust and ADCadjust constants? My primary purpose is to see how high my kite is using 433hmz rf link, so true height above see level is not critical, only the difference between ground level and the height of the kite. What I can't get my head around is the 2 variable unknowns for a portable device - actual height above sea level, and the atmospheric pressure at that location.

Texy
 
Last edited:

matherp

Senior Member
Texy

The MPX4115 outputs 3.848 volts with an atmospheric pressure of 96.0667 KPa (960.667 Mb). As I am offsetting the voltage measurement by 3.848 volts I need to add this into the reading from the ADC. Because the ADC is reading 4 counts per mb, I multiply 960.667 by 4 to give 3843 as an offset to add into the ADC value. Then when I divide this new value by 4 I get the actual pressure in Mb.

The Heightadjust parameter takes into account the distance the sensor is above sea level. Roughly pressure reduces by 1mb for each 30ft above sea level. So if sea level pressure is 1013mb then the measured pressure at 300ft above sea level will be 1003. My house is roughly 250ft above sea level so 250 / 30 = 8.33 Mb which equates to 8.3 * 4 = 33 ADC counts. This will vary depending upon the height above sea level of each particular instrument. Good quality barometers allow you to adjust this to give the sea level pressure.

For your application just measure the pressure difference between the field and the kite in mb. Multiplying this by 30 will give a rough height in feet. Google will point you to the calculations to get it more accurately but these are heavy duty floating point outside the capability of a picaxe.
 

Texy

Senior Member
Thanks for the explanation. I will be using lookup tables to store the height calculations generated using the Z(ft) = - 26216 * ln( P(kPa) / 101.304) formula in excel. Thanks also for pointing out the adcconfig command, as I was not aware of it. Its a real shame that both -ve and +ve reference voltages couldn't be used for the smaller pincount picaxes, but your choice of using the 18M2 and the -vref pin is probably the best without further signal conditioning.

Rgds,
Texy
 

kurtee

New Member
Matherp,

Let me get this right...
I can put a negative voltage of 3.848volts on pin C2 of the 18M2?
 

Texy

Senior Member
Matherp,

Let me get this right...
I can put a negative voltage of 3.848volts on pin C2 of the 18M2?
No. You can use the -vref pin to set the low base level setting.
So if you set a -vref voltage of 1volt and the voltage of the adc pin is 1v, then the readadc reading will be 0.
Texy
 

kurtee

New Member
Thanks Texy!
I was thinking that you had to put a negative voltage in to do level shifting!
So, what ever fixed positive voltage I put on C2, when the analog input reads a voltage equal to that reference voltage that will represent a 0 bit weight on the A/D.
Right...
 
Top