BMP085 Altitude Problem

Hi to all
I am new to Arduino.
So i bought a BMP085 sensor and i have manage to read from it pressure and temperature.
But the altitude somehow is very starnge.
I know that the sensor calculates the altitude from barometic pressure but is there any code that i have to put in project to get the right altitude?

Altitude is calculated from the current pressure at your location AND the sea level pressure, which you have to specify.

Post the details of your project, after reading the "How to use this forum" post.

I Googled "Altimeter Correction" and the references I found imply that corrections are linear and you should add altitude when it's cold. It seem strange but they didn't mention current barometic pressure, but maybe pilots already calibrate to the known airport elevation when they take off???

OK Sorry .
This is teh code
Very simple

#include <Wire.h>
#include <Adafruit_BMP085.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
 
LiquidCrystal_I2C lcd(0x27,20,4);
Adafruit_BMP085 bmp;
   
void setup() {
 
  lcd.init(); 
  lcd.backlight();
  if (!bmp.begin()) {
  lcd.print("ERROR, check wiring!");
    while (1) {}
}
   
void loop() {
/*
 * this sensor is very powerful, you can even read 
 * temperature with it with this function:
 * bmp.readTemperature()
 */
 
    //read pressure
    lcd.setCursor(0, 0);
    lcd.print("Pres: ");
    lcd.print(bmp.readPressure()/100);
    lcd.print(" hPa");


    //read altitude
    lcd.setCursor(0, 1);
    lcd.print("Alt: ");
    lcd.print(bmp.readAltitude(), 1);
    lcd.print(" m");

     //read temperature
    lcd.setCursor(0, 2);
    lcd.print("Temp: ");
    lcd.print(bmp.readTemperature(), 1);
    lcd.print((char) 223);
    lcd.print(" C");

  delay(1000);
}

maybe pilots already calibrate to the known airport elevation when they take off?

Yes, we do. Either dial in the field elevation if known (my home field is 268 feet for example), or the altimeter setting if the field has a system that is broadcasting it.

Call on the phone for it, or listen on the radio if in the plane.

Airports in my state for example:

The library is not simple. Start with the example that comes with it, rather than something that some idiot* posted on the web.

Set the current "sea level pressure" properly.

Note: the "current sea level pressure" can be calculated from the current pressure at elevation, and the known elevation. But these change with the weather, so you have to recalibrate the sensor from time to time.

  • judging from this comment in the code:
/*
 * this sensor is very powerful, you can even read
 * temperature with it with this function:
 * bmp.readTemperature()
 */

jremington:
The library is not simple. Start with the example that comes with it, rather than something some idiot posted on the web.

Set the current "sea level pressure" properly.

Note: the "current sea level pressure" can be calculated from the current pressure at elevation, and the known elevation.

Trying to learn.
Any example code to test please?

Any example code to test please?

It is in the library that you downloaded.

jremington:
It is in the library that you downloaded.

Thank you for your help.
I will test