Hi,
I just added a barometric pressure sensor to my outdoor node.
My house is 310 meters above sea level, so I have to adjust the pressure readings to get the Mean Sea Level Pressure.
In order to save the battery on my sensor I have adjusted EmonCMS to do the calculation for me.
I modified the file Models/process_model.php:
Added to the end of the get_process_list() function:
$list[20] = array( _("MSLP"), ProcessArg::VALUE, "calculateMSLP", 0, DataType::UNDEFINED );
And added to the end of the file:
// Calculate the Mean Sea Level Pressure based on altitude (in meters) of the sensor // and the local station pressure in millibars function calculateMSLP($altitude_in_meters, $time, $pressure_in_millibars){ $F1 = (pow(1013.25, 0.190284) * 0.0065)/288; $F2 = $altitude_in_meters/pow(($pressure_in_millibars - 0.3), 0.190284); $F3 = 1/0.190284; $F = pow((1 + ($F1 * $F2)), $F3); return ($pressure_in_millibars - 0.3) * $F; }
To use, click on the item in the INPUT list, then add a new process 'MSLP' and enter the height in meters above sea level as the argument.
Regards
Ian
--
Re: Mean Sea Level Pressure
Nice work! great to see that you found your way around the input processing, thanks for sharing
Re: Mean Sea Level Pressure
Not that I understand any of this code really, but I wonder why you're re-calculating $F1 and $F3 each time. Can their values ever change?
Re: Mean Sea Level Pressure
Hi,
Yes you're right they are constant and could be moved outside the function or prefilled. The actual time processing is tiny so wouldn't really cause problems.
For reference, I got the function from this online calculator:
http://www.srh.noaa.gov/epz/?n=wxcalc_altimetersetting
I have no idea what those constants are in the equation and my brief searches were futile. I just know it works and matches up with other local values from the Met Office ;)
Ian
--
Re: Mean Sea Level Pressure
I just wonder why you need to use that degree of complication and precision?
The rule of thumb is the pressure reduces by one millibar for every 30 feet of altitude. That assumes a linear relationship, which isn't true, but for normal purposes - up to about 10,000 ft, the resulting error is insignificant. For most practical purposes you could simply subtract a constant 33.9 mb.
(To put the numbers into perspective, the pressure upstairs is about ¼ mb lower than it is down).
[Edit: Of course, you ADD to convert your measured pressure to sea level. Other locations will vary ! ]
Re: Mean Sea Level Pressure
Hi,
I have no knowledge of meteorology so had no idea of this rule of thumb you speak of.
I am working on a way to automatically submit the info to the the Met Office WOW service:
http://wow.metoffice.gov.uk/home
It looks fairly simple as they have a web API I can use but some of the fields are missing from their online docs. I have sent a message to them asking for more info and am awaiting a response from their tech guys.
It would be nice to add this ability to EmonCMS via some simply forms. But to create this I need to know all the variables.
Regards
Ian