AI-Powered AC Temperature Prediction System is an intelligent air conditioner temperature predicting system that optimizes indoor temperature settings using machine learning, real-time sensor data, and external weather conditions. Developed in Python, it integrates with Firebase for data storage and retrieval, and uses the OpenWeather API to fetch outdoor weather conditions. The system predicts optimal AC set temperatures based on indoor conditions, user feedback, and environmental factors.
This app is one of my contributions to our group project, the Smart-AC-Control-System, which encompasses a broader system for controlling AC units, including gathering indoor and outdoor sensor data, checking occupancy, predicting optimal AC set temperatures using AI models, and automating an exhaust fan system etc. For more details on the main project, visit the repository at Smart-AC-Control-System.
The AI-Powered AC Temperature Prediction System is designed to enhance comfort and energy efficiency by dynamically adjusting air conditioner settings. It:
- Collects indoor temperature and humidity from sensors stored in Firebase.
- Fetches outdoor weather data (temperature, humidity, weather condition) via the OpenWeather API.
- Uses a pre-trained machine learning model to predict the optimal AC temperature.
- Incorporates user feedback and activity type to personalize predictions.
- Updates Firebase with predicted temperatures and environmental data for real-time control.
This project is ideal for smart home applications, energy-efficient HVAC systems, or IoT-based climate control solutions.
- 🌡️ Real-Time Sensor Data: Retrieves indoor temperature and humidity from Firebase.
- ☁️ Weather Integration: Fetches outdoor weather data using the OpenWeather API.
- 🧠 ML Predictions: Uses a pre-trained model to predict optimal AC set temperatures.
- 🕹️ User Feedback: Incorporates user activity and comfort feedback for personalized settings.
- 📡 Firebase Integration: Stores and retrieves data for seamless real-time operation.
- 🔄 Continuous Operation: Runs in a loop, updating predictions every 20 seconds.
- ⚡ Energy Efficiency: Optimizes AC settings to balance comfort and energy usage.
- Python 3.10+ – Core programming language
- Firebase Admin SDK – For real-time database integration
- Joblib – For loading the pre-trained ML model
- Pandas & NumPy – For data manipulation and preparation
- Requests – For OpenWeather API calls
- OpenWeather API – For fetching outdoor weather data
- Python-dotenv – For environment variable management
The machine learning model was trained on a dataset with the following features:
| Feature | Description |
|---|---|
indoor_temp |
Indoor temperature (°C) |
indoor_humidity |
Indoor humidity (%) |
occupancy |
Room occupancy (0 or 1) |
weather |
Outdoor weather condition (e.g., Clear, Rain) |
time_of_day |
Hour of the day (0–23) |
outdoor_temp |
Outdoor temperature (°C) |
outdoor_humidity |
Outdoor humidity (%) |
user_feedback |
User comfort feedback (e.g., Comfortable, Too cold) |
activity_type |
User activity (e.g., Relaxing) |
last_set_temp |
Previous AC set temperature (°C) |
A small sample of the dataset is included in the project description for reference.
- Sensor Data Retrieval: Fetches indoor temperature, humidity, user feedback, and activity type from Firebase.
- Weather Data Fetching: Queries the OpenWeather API for outdoor temperature, humidity, and weather conditions.
- Data Preparation: Combines sensor and weather data into a format compatible with the ML model.
- Prediction: Uses the pre-trained model to predict the optimal AC set temperature.
- Firebase Update: Writes the predicted temperature and environmental data back to Firebase.
- Python 3.10+
- All dependencies listed in
requirements.txt - Firebase Admin SDK credentials
- OpenWeather API key
- Pre-trained ML model (
ac_model.pkl)
-
Clone the Repository:
git clone https://github.com/SahanUday/AI-Powered-AC-Temperature-Prediction-System.git cd AI-Powered-AC-Temperature-Prediction-System -
Install Dependencies:
pip install -r requirements.txt
-
Set Up Environment Variables:
- Copy the environment template:
cp .env.template .env
- Edit
.envfile and add your actual values:OPENWEATHER_API_KEY=your_openweather_api_key_here LATITUDE=your_latitude LONGITUDE=your_longitude FIREBASE_CREDENTIALS_PATH=your_firebase_credentials.json FIREBASE_DATABASE_URL=https://your-project-default-rtdb.region.firebasedatabase.app/
- Copy the environment template:
-
Set Up Firebase Credentials:
- Download your Firebase Admin SDK service account JSON file from Firebase Console
- Save it in your project directory (the filename should match
FIREBASE_CREDENTIALS_PATHin your.env) - Important: This file contains sensitive data and should NEVER be committed to version control
-
Get OpenWeather API Key:
- Sign up at OpenWeatherMap
- Get your free API key
- Add it to your
.envfile
-
Place the ML Model:
- Ensure the pre-trained model file (
ac_model.pkl) is in the project root.
- Ensure the pre-trained model file (
-
Run the Project:
python main.py
The script will fetch data from Firebase and OpenWeather API, make predictions, and update Firebase with the results.
AI-Powered-AC-Temperature-Prediction-System/
├── main.py # Main script with ML prediction logic
├── ac_model.pkl # Pre-trained ML model
├── requirements.txt # Python dependencies
├── .env.template # Environment variables template
├── firebase-config-template.json # Firebase credentials template
├── .gitignore # Git ignore rules (protects sensitive files)
└── README.md # Project documentation
- First Run: The script will validate your environment configuration
- Data Fetching: Retrieves indoor sensor data from Firebase
- Weather Data: Fetches outdoor conditions from OpenWeather API
- ML Prediction: Uses the trained model to predict optimal AC temperature
- Firebase Update: Writes prediction and environmental data back to Firebase
From Firebase -> Temp: 26.5°C, Humidity: 65%
From Firebase -> activity_type: Relaxing, status: Comfortable
From OpenWeather -> Outdoor Temp: 28.3°C, Outdoor Humidity: 78%, Weather: Clear, Hour: 14
🎯 Predicted AC Set Temperature: 24.2°C
✅ Written to Firebase: /sensor_data/ai_set_temp -> cool_24
Contributions are welcome! Potential enhancements include:
- 📈 Adding support for multiple rooms or zones
- 🧠 Improving the ML model with more features
- 🖥️ Building a web dashboard for monitoring
- 🔌 Integrating with IoT devices for direct AC control
- 🔒 Adding authentication and user management
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature) - Never commit sensitive files (
.env, credentials) - Test your changes thoroughly
- Commit your changes (
git commit -m "Add your feature") - Push to the branch (
git push origin feature/your-feature) - Submit a pull request