Complete Tutorial: Altitude Measurement & Weather Prediction
The BMP180 is a digital barometric pressure sensor by Bosch for altitude measurement and weather monitoring. It measures atmospheric pressure (which decreases with elevation) and includes a temperature sensor for compensated readings.
| Parameter | Specification |
|---|---|
| Operating Voltage | 1.8V – 3.6V (module: 3.3V – 5V) |
| Interface | I2C (address: 0x77 fixed) |
| Pressure Range | 300 – 1100 hPa |
| Pressure Accuracy | ±0.12 hPa |
| Temperature Range | -40°C to +85°C |
| Temperature Accuracy | ±1.0°C |
| Current Consumption | 5 µA @ 1 sample/sec |
Altitude = 44330 × (1 - (P / P₀)^0.1903)
Where P = measured pressure, Pâ‚€ = sea level pressure (1013.25 hPa)
| BMP180 Pin | ESP32 | Arduino Uno |
|---|---|---|
| VCC | 3.3V | 3.3V |
| GND | GND | GND |
| SCL | GPIO 22 | A5 |
| SDA | GPIO 21 | A4 |
Figure 1: BMP180 I2C wiring with ESP32
Install Adafruit BMP085 Library via Arduino Library Manager.
#include <Wire.h>
#include <Adafruit_BMP085.h>
#define SEALEVEL_PRESSURE 101325 // Adjust for your location
Adafruit_BMP085 bmp;
void setup() {
Serial.begin(115200);
Serial.println("BMP180 Altitude Monitor");
if (!bmp.begin()) {
Serial.println("ERROR: BMP180 not found!");
while (1);
}
Serial.println("BMP180 Ready!");
}
void loop() {
float temp = bmp.readTemperature();
float pressure = bmp.readPressure();
float altitude = bmp.readAltitude(SEALEVEL_PRESSURE);
Serial.println("------------------------");
Serial.print("Temperature: "); Serial.print(temp); Serial.println(" C");
Serial.print("Pressure: "); Serial.print(pressure/100); Serial.println(" hPa");
Serial.print("Altitude: "); Serial.print(altitude); Serial.println(" m");
// Weather forecast
float hPa = pressure / 100.0;
if (hPa > 1022) Serial.println("Forecast: Clear skies");
else if (hPa > 1013) Serial.println("Forecast: Fair");
else if (hPa > 1000) Serial.println("Forecast: Cloudy");
else Serial.println("Forecast: Stormy");
delay(3000);
}