β Back to Course
BME280/BMP280 - Barometric Pressure and Altitude
π BME280/BMP280 - Pressure, Altitude, and Weather Prediction
π What You'll Learn:
- π‘οΈ Measure temperature, humidity, and barometric pressure
- π Predict rain 12-24 hours in advance from pressure trends
- π Wire BME280/BMP280 using I2C (SDA/SCL pins)
- π° Choose BME280 ($10-15) or BMP280 ($5-8)
π Sensor Comparison
- π‘οΈ BME280 ($10-15): Temperature + Humidity + Pressure β Complete weather station
- π BMP280 ($5-8): Temperature + Pressure only β Budget option, no humidity
π‘ Which to Choose?
BME280 is worth the extra $5 for humidity data - critical for disease prediction and crop stress monitoring. BMP280 is fine if you only need pressure for weather forecasting.
π I2C Wiring (Both sensors same)
BME280/BMP280 ESP32
βββββββββββββββ ββββββββ
VCC ββββββΊ 3.3V
GND ββββββΊ GND
SDA ββββββΊ GPIO21
SCL ββββββΊ GPIO22
I2C Address: 0x76 (SDO to GND) or 0x77 (SDO to 3.3V)
π Complete Code
#include <Wire.h>
#include <Adafruit_BME280.h>
Adafruit_BME280 bme;
float lastPressure = 0;
void setup() {
Serial.begin(115200);
Wire.begin();
if (!bme.begin(0x76)) {
Serial.println("β Sensor not found!");
while(1);
}
Serial.println("β
BME280 ready");
}
void loop() {
float temp = bme.readTemperature();
float hum = bme.readHumidity();
float pressure = bme.readPressure() / 100.0F;
float trend = pressure - lastPressure;
Serial.println("ββββββββββββββββββββββββ");
Serial.printf("π‘οΈ Temp: %.1fΒ°C\n", temp);
Serial.printf("π§ Humidity: %.0f%%\n", hum);
Serial.printf("π Pressure: %.0f hPa\n", pressure);
// Weather prediction
if (trend > 2) {
Serial.println("βοΈ Rising pressure - Good weather coming");
} else if (trend < -2) {
Serial.println("π§οΈ Falling pressure - Rain likely soon!");
} else {
Serial.println("β‘οΈ Stable pressure - Conditions continue");
}
lastPressure = pressure;
delay(60000);
}
π‘ Weather Prediction Rules:
- π§οΈ Pressure drop > 2 hPa/hour: Rain likely in 12-24 hours
- βοΈ Pressure rise > 2 hPa/hour: Clearing weather
- β‘οΈ Stable pressure (Β±1 hPa): Current conditions continue
- π Rapid drop > 4 hPa/hour: Storm approaching!
π― Key Takeaways:
- β BME280 = Temp + Humidity + Pressure ($10-15)
- β BMP280 = Temp + Pressure only ($5-8)
- π I2C pins: SDAβGPIO21, SCLβGPIO22
- π§οΈ Pressure drop = rain coming β reduce irrigation
π‘ Key Takeaways:
- Apply these concepts directly to your farm or project.
- Take notes on important details for the quiz.
- Use the button below to track your progress.
×