Bmp180 - Calculating altitude
Altitude can be calculated by measuring the pressure, knowing the baseline pressure, and then using the altitude() function.
⚠️
To calculate altitude, you should have a recent reading of the pressure at sea level for your location. Without it, the values will be very inaccurate.
//...
bmp180.getPressure(pressure, temperature);
// Average sea level pressure (Getting a location-specific pressure is far more precise)
double pressure_at_sea_level = 1013.25;
double altitude = bmp180.altitude(pressure, pressure_at_sea_level);
Serial.println("Current altitude: "+String(altitude)+" m");
//...

Serial monitor
bmp180.altitude(double P, double P0)
Calculates altitude in meters based on the pressure reading and the baseline pressure at sea level.
Returns value: Double value, the altitude in meters
Function parameters:
| Type | Name | Description |
|---|---|---|
double | P | Absolute pressure value in mbars |
double | P0 | Baseline pressure at sea level in mbars |
Full example
Try all the functions mentioned in this documentation through this example:
TempAndPressure.ino
Example file for using BMP180 sensor with easyC/Qwiic/I2C