#include <iostream>
#include <string>
using namespace std;
// -----------------------------------------------------
// MOCK SENSOR FUNCTIONS (Replace with real sensor code)
// -----------------------------------------------------
float readDHT11Temperature() { return 25.0; } // Example data
float readDHT11Humidity() { return 55.0; }
float readLM35Temperature() { return 24.5; }
float readDS18B20Temperature(){ return 25.2; }
bool readRainSensor() { return false; } // false = NO rain, true = RAIN
bool readMoistureSensor() { return false; } // false = DRY, true = WET
bool readWaterLevelSensor() { return false; } // false = NORMAL, true = HIGH
int readMQ135() { return 250; } // Higher = more polluted
bool readLDR() { return true; } // true = Bright, false = Dark
int readBMP180Pressure() { return 101325; }
float readBMP180Altitude() { return 45.6; }
bool readWindSensor() { return false; } // false = normal, true = high wind
// -----------------------------------------------------
// WINDOW CONTROL (Mock Servo Motor)
// -----------------------------------------------------
void openWindow() {
cout << "🪟 Window State : OPENED\n";
}
void closeWindow() {
cout << "🪟 Window State : CLOSED\n";
}
// -----------------------------------------------------
// MAIN PROGRAM
// -----------------------------------------------------
int main() {
cout << "\n========== AUTOMATIC CLIMATE SENSITIVE WINDOW ==========\n\n";
// ------------ READ ALL SENSORS -----------------
float dhtTemp = readDHT11Temperature();
float dhtHum = readDHT11Humidity();
float lm35 = readLM35Temperature();
float ds18b20 = readDS18B20Temperature();
bool rain = readRainSensor();
bool moist = readMoistureSensor();
bool water = readWaterLevelSensor();
int air = readMQ135();
bool light = readLDR();
int pressure = readBMP180Pressure();
float altitude= readBMP180Altitude();
bool wind = readWindSensor();
// ------------ DISPLAY SENSOR DATA ---------------
cout << "📡 SENSOR READINGS:\n";
cout << "-----------------------------------------------------\n";
cout << "DHT11 Temperature : " << dhtTemp << " °C\n";
cout << "DHT11 Humidity : " << dhtHum << " %\n";
cout << "LM35 Temperature : " << lm35 << " °C\n";
cout << "DS18B20 Temp : " << ds18b20 << " °C\n";
cout << "Rain Sensor : " << (rain ? "RAINING" : "NO RAIN") << "\n";
cout << "Soil Moisture : " << (moist ? "WET" : "DRY") << "\n";
cout << "Water Level : " << (water ? "HIGH" : "NORMAL") << "\n";
cout << "Air Quality (MQ135): " << air << " (higher = polluted)\n";
cout << "Light Sensor (LDR): " << (light ? "BRIGHT" : "DARK") << "\n";
cout << "BMP180 Pressure : " << pressure << " Pa\n";
cout << "BMP180 Altitude : " << altitude << " m\n";
cout << "Wind Sensor : " << (wind ? "HIGH WIND" : "NORMAL") << "\n";
cout << "-----------------------------------------------------\n\n";
// ------------ DECISION LOGIC -------------------
cout << "🤖 SYSTEM DECISION:\n";
// Best temperature source
float finalTemp = dhtTemp;
if (finalTemp == 0) finalTemp = lm35;
if (finalTemp == 0) finalTemp = ds18b20;
// Safety first
if (rain) {
cout << "🌧 Rain Detected → Window Closed\n";
closeWindow();
}
else if (wind) {
cout << "💨 High Wind → Window Closed\n";
closeWindow();
}
else if (water) {
cout << "💧 High Water Level → Window Closed\n";
closeWindow();
}
else if (air > 400) {
cout << "🌫 Poor Air Quality → Window Closed\n";
closeWindow();
}
// Temperature logic
else if (finalTemp < 20) {
cout << "❄ Too Cold → Window Closed\n";
closeWindow();
}
else if (finalTemp > 30) {
cout << "☀ Too Hot → Window Closed\n";
closeWindow();
}
else if (moist) {
cout << "💧 Moisture Detected → Window Closed\n";
closeWindow();
}
else {
cout << "🌤 Comfortable Range → Window Opened\n";
openWindow();
}
cout << "\n=======================================================\n";
return 0;
}