OC
OceanRemote
Low-code IoT platform
← Back to Course

BME280/BMP280 - Barometric Pressure and Altitude

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.