For everybody who's toying around with weather balloons...
Have fun!
/* *** Pressure altitude calculation ***
* Original equation by Steve Randall (http://randomaerospace.com):
* a [m] = ln(p0 [Pa] / p [Pa]) * 7238,3 [m]
* a [m]:Â altitude;Â Â Â Â Â Â Â Â Â Â Â Â Â unit: Meter
* p0 [Pa]: pressure at sea level;Â Â Â Â Â Â unit: Pascal
* p [Pa]:Â pressure at altitude to calculate; unit: Pascal
* 7238,3:Â correcture factor, found by Steve; unit: must be in Meter to do it mathematically correct.
* In this sketch equation is adapted to Arduino's language.
* You always have to use long-variables because integer will fail at altitudes above 32.768 km resp. pressure less than 1096 Pa.
* Suggested pressure sensor: MS5607 ... MS5611 Series
*/
long pressureInPascal;
long druckhoehe;
void setup() {
 Serial.begin(9600);
 delay(2000);
 Serial.println("Demonstration der Druckhoehenkalkulation.\nDie hier verwendete Gleichung ist bis 80 km gueltig.");
}
void loop() {
 Serial.println("Eingabe (Druck in Pascal):");
 pressureInPascal = longInput();
 druckhoehe = calcPressureAltitude(pressureInPascal);
 Serial.println("Der Druck von " + String(pressureInPascal) + " Pa entspricht einer Hoehe von " + String(druckhoehe) + " Metern.");
}
// Function calculation of pressure altitude
long calcPressureAltitude(long _PressureInPascal) {
 long _Temp = (log(101325.0 / _PressureInPascal) * 72383.0);
 long _PressureAltitude = 0;
 if (_Temp % 10 > 5) {
  _PressureAltitude = 1;
 }
 _PressureAltitude = _PressureAltitude + long(_Temp / 10);
 return _PressureAltitude;
}
// input function
long longInput() {
 long _Result;
 char _Space = ' ';Â
 while (Serial.available() == 0); {
  delay(3);
  _Result = Serial.parseFloat();
  while (Serial.available() > 0) {
   _Space = Serial.read();
  };
 };
 return _Result;
};
/* *** Pressure altitude calculation ***
* Original equation by Steve Randall (http://randomaerospace.com):
* a [m] = ln(p0 [Pa] / p [Pa]) * 7238,3 [m]
* a [m]:Â altitude;Â Â Â Â Â Â Â Â Â Â Â Â Â unit: Meter
* p0 [Pa]: pressure at sea level;Â Â Â Â Â Â unit: Pascal
* p [Pa]:Â pressure at altitude to calculate; unit: Pascal
* 7238,3:Â correcture factor, found by Steve; unit: must be in Meter to do it mathematically correct.
* In this sketch equation is adapted to Arduino's language.
* You always have to use long-variables because integer will fail at altitudes above 32.768 km resp. pressure less than 1096 Pa.
*/
long pressureInPascal;
long altitudePressure;
void setup() {
 Serial.begin(9600);
 delay(2000);
 Serial.println("Demonstration of pressure altitude calkulation.\nEquation used here is valid until 80 km.");
}
void loop() {
 Serial.println("Input (Pressure in Pascal):");
 pressureInPascal = longInput();
 altitudePressure = calcPressureAltitude(pressureInPascal);
 Serial.println("A pressure of " + String(pressureInPascal) + " Pa equals to an altitude of " + String(altitudePressure) + " Meters.");
}
// Function calculation of pressure altitude
long calcPressureAltitude(long _PressureInPascal) {
 long _Temp = (log(101325.0 / _PressureInPascal) * 72383.0);
 long _PressureAltitude = 0;
 if (_Temp % 10 > 5) {
  _PressureAltitude = 1;
 }
 _PressureAltitude = _PressureAltitude + long(_Temp / 10);
 return _PressureAltitude;
}
// input function
long longInput() {
 long _Result;
 char _Space = ' ';Â
 while (Serial.available() == 0); {
  delay(3);
  _Result = Serial.parseFloat();
  while (Serial.available() > 0) {
   _Space = Serial.read();
  };
 };
 return _Result;
};
/* *** Pressure altitude calculation ***
* Original equation by Steve Randall (http://randomaerospace.com):
* a [m] = ln(p0 [Pa] / p [Pa]) * 7238,3 [m]
* a [m]:Â altitude;Â Â Â Â Â Â Â Â Â Â Â Â Â unit: Meter
* p0 [Pa]: pressure at sea level;Â Â Â Â Â Â unit: Pascal
* p [Pa]:Â pressure at altitude to calculate; unit: Pascal
* 7238,3:Â correcture factor, found by Steve; unit: must be in Meter to do it mathematically correct.
* In this sketch equation is adapted to Arduino's language.
* You always have to use long-variables because integer will fail at altitudes above 32.768 km resp. pressure less than 1096 Pa.
* Suggested pressure sensor: MS5607 ... MS5611 Series.
*/
long pressureInPascal;
long altitudePressure;
void setup() {
 Serial.begin(9600);
 delay(2000);
 Serial.println(F("Demonstration of pressure altitude calkulation.\nEquation used here is valid until 80 km."));
}
void loop() {
 Serial.println(F("Input (Pressure in Pascal):"));
 pressureInPascal = longInput();
 altitudePressure = calcPressureAltitude(pressureInPascal);
 Serial.println("A pressure of " + String(pressureInPascal) + " Pa equals to an altitude of " + String(altitudePressure) + " Meters.");
}
// Function calculation of pressure altitude
long calcPressureAltitude(long _PressureInPascal) {
 long _Temp = (log(101325.0 / _PressureInPascal) * 72383.0);
 long _PressureAltitude = 0;
 if (_Temp % 10 > 5) {
  _PressureAltitude = 1;
 }
 _PressureAltitude = _PressureAltitude + long(_Temp / 10);
 return _PressureAltitude;
}
// input function
long longInput() {
 long _Result;
 char _Space = ' ';Â
 while (Serial.available() == 0); {
  delay(3);
  _Result = Serial.parseFloat();
  while (Serial.available() > 0) {
   _Space = Serial.read();
  };
 };
 return _Result;
};