in getEstimatedAltitude a new formula been invented to calculate the altitude. In that formula the *ground* temperature of the atmosphere should be used. Here at *every calculation* the baro chip temperature is used. (not correctly copied from arducopter). Unfortunately this temperature climbs in the first minutes of operation (at least on BMP085) about 15 degrees above environment temperature.
I suggest to set the temperature either constant (for example 10 degrees C) or set it only at calibration time, which will even speed up the code..
Here the code to set it at calibration time:
Code: Select all
uint8_t getEstimatedAltitude(){
...
static float baroGroundTemperatureScale;
...
if(calibratingB > 0) {
...
baroGroundTemperatureScale = (baroTemperature + 27315) * 29.271267f;
...
}
calibratingB--;
}
...
BaroAlt = log( baroGroundPressure * (BARO_TAB_SIZE - 1)/ (float)baroPressureSum ) * baroGroundTemperatureScale; // in cemtimeter