So for the past week, I have been frantically looking around the internet trying to find out how I can use a BMP280 pressure sensor to calculate altitude above ground level.
I understand that I need to know the pressure at ground level, and some math roughly along the lines of:
"if pressure is = X, then altitude is =Y"
I have heard that it is possible for the sensor to read pressure as 0 when turned on, and then every meter in altitude, the pressure increases by 0.121738 millibars. How would I go about getting the sensor to read 0 when turned on?
I understand that. But I think that it would be much easier for the pressure sensor to just read 0 once turned on, and then track the pressure as it rises in altitude.
Okay. could you maybe provide me with some code? maybe a link? And where would I enter zero as the altitude?
I am very new to using sensors and using their data to preform actions. My end goal is to use the maximum altitude of a model rocket to calculate it's velocity when it hits the ground. from this information, I can determine when to ignite a rocket motor to land it similar to BPS.space.
You can read the sensor when it is turned on, then store that value as the zero altitude reference, making all the following calculations based on the difference between that value and the current value.
You will also need to consider other factors, such as air density, temperature, wind speed and direction, drag of the rocket, etc. Propulsive landing using a solid rocket motor is going to be extremely difficult.
I know that it is going to be difficult, and it does not need to be exact. I am planning on incorporating those factors later on.
Let me clarify a little, right now, I need to find out how to code this:
"When the BMP280 turns on, it reads the pressure at the current altitude. Using the number that air pressure drops at per meter of increased altitude, calculate the altitude in meters. "
That is all I need. I have figured out some equations to calculate the best time to burn the motor on my own.
That seems very straightforward, you take a reading of the pressure at ground level (presumably when the power is turned on the rocket is sitting on the ground). Store that value as the ground reference. To calculate altitude about ground level, take a reading of the current pressure, subtract the ground reference, and you now have the pressure differential with which to calculate the altitude.
in the library above, if in your setup you call bmp.readAltitude(1013.25) then you get some sort of a reference altitude if the sea level hPa was 1013.25 (which is the average pressure at mean sea-level (MSL) in the International Standard Atmosphere (ISA)). Store this in a float variable startAltitude.
Then later when you call again bmp.readAltitude(1013.25), if you want the relative altitude, just subtract startAltitude.
You could modify the library to provide a setReference() and a readRelativeAltitude() methods that would "hide" this math away for you...
Okay, that sounds pretty simple. I m definitely going to need to come back and read this post a few more times though! HAHAHA.
Thanks for all of the help!