OC
OceanRemote
Low-code IoT platform
← Back to Course

Complete Weather Station Integration

🗼 Complete Weather Station - All Sensors Combined

📖 Combined Code (DHT22 + BMP280):

#include 
#include 
#include "DHT.h"

#define DHTPIN 16
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);
Adafruit_BME280 bme;

void setup() {
    Serial.begin(115200);
    dht.begin();
    bme.begin(0x76);
    Serial.println("Complete Weather Station Ready");
}

void loop() {
    // DHT22 readings
    float tempDHT = dht.readTemperature();
    float humDHT = dht.readHumidity();
    
    // BME280 readings
    float tempBME = bme.readTemperature();
    float pressure = bme.readPressure() / 100.0F;
    
    // Use average for better accuracy
    float tempAvg = (tempDHT + tempBME) / 2;
    
    Serial.println("=== WEATHER REPORT ===");
    Serial.printf("🌡️ Temperature: %.1f°C\n", tempAvg);
    Serial.printf("💧 Humidity: %.1f%%\n", humDHT);
    Serial.printf("📊 Pressure: %.1f hPa\n", pressure);
    
    // Combined recommendations
    if (tempAvg > 35 && humDHT < 30) {
        Serial.println("⚠️ HIGH HEAT + LOW HUMIDITY - Severe plant stress!");
        Serial.println("   → Increase irrigation, provide shade");
    } else if (tempAvg > 30) {
        Serial.println("⚠️ Hot conditions - Water more frequently");
    } else if (tempAvg < 10) {
        Serial.println("⚠️ Cold - Protect sensitive crops");
    }
    
    if (humDHT > 80) {
        Serial.println("⚠️ High humidity - Check for fungal disease");
    }
    
    delay(60000);
}
    
✅ Professional Weather Station Features:
  • Real-time temperature monitoring
  • Humidity tracking for disease prevention
  • Pressure-based storm prediction
  • Data logging to SD card (optional)
  • Cloud upload to OceanRemote
💡 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.