This code is straight out of the Adafruit BMP085 sample code and library.
But obviously I'm doing something wrong, because its returning.
23140.43 as the altitude. When I'm practically at sea level as it is. Maybe a 10 or so meters above sea level, but not 23,140 meters ....
The code is from the BMP085_U library basically.
The Arduino + Weathershield is returning everything else ok,
/* -------------- Get the altitude ---------------------- */
/**************************************************************************/
/*!
Calculates the altitude (in meters) from the specified atmospheric
pressure (in hPa), sea-level pressure (in hPa), and temperature (in ?C)
@param seaLevel Sea-level pressure in hPa
@param atmospheric Atmospheric pressure in hPa
@param temp Temperature in degrees Celsius
*/
/**************************************************************************/
/* Hyposometric formula: */
/* */
/* ((P0/P)^(1/5.257) - 1) * (T + 273.15) */
/* h = ------------------------------------- */
/* 0.0065 */
/* */
/* where: h = height (in meters) */
/* P0 = sea-level pressure (in hPa) */
/* P = atmospheric pressure (in hPa) */
/* T = temperature (in ?C) */
const uint32_t seaLevel, P0 = 1013.25;
float pow (double base, double exponent);
uint32_t temp, T = t;
temp = t; // returned by sensor above, degrees C
uint32_t atmospheric, P = p; // pressure in hpa
uint32_t h, altitude; //height in meters
h = (((float)pow((P0/P), 0.190223F) - 1.0F) * (T + 273.15F)) / 0.0065F;
//h = (((float)pow((seaLevel/atmospheric), 0.190223F) - 1.0F)
// * (temp + 273.15F)) / 0.0065F;
altitude = h;
putchar(',');
utoa(altitude/100, buffer, 10);
usart_puts(buffer);
putchar('.');
if (altitude%100 < 10)
{
putchar('0');
}
utoa(altitude%100, buffer, 10);
usart_puts(buffer);
/*---------------------------------------------------------*/
Output of Arduino at present. Debug mode is on.
HEX,05,0d,a5,71,a8,10,TEMPERATURE:17.1
HEX,55,0d,a6,1f,9e,40,HUMIDITY:61
HEX,35,0d,a1,df,e2,20,WINDDIRECTION:NNW WINDSPEED:2.9
HEX,b5,0d,a3,60,c9,b0,GUSTDIRECTION:N GUSTSPEED:5.4
HEX,05,0d,a5,71,a8,10,TEMPERATURE:17.1
HEX,55,0d,a6,1f,9e,40,HUMIDITY:61
HEX,35,0d,a1,df,e2,20,WINDDIRECTION:NNW WINDSPEED:2.9
HEX,b5,0d,a3,60,c9,b0,GUSTDIRECTION:N GUSTSPEED:5.4
--END--
I2C UT=26976
I2C T=21
I2C UP=334676
I2C P=1007.36
80,27,27,17.1,61,-,N ,5.4,NNW,2.9,1007.36,23140.43
Indoor Temp=21.2