This repository contains a comprehensive Air Quality Index (AQI) prediction and monitoring system for Delhi, combining hardware sensors, machine learning, and mobile applications to provide real-time air quality information and predictions.
The system consists of three integrated components:
- Flutter Mobile Application - User-friendly interface for monitoring AQI levels
- ML Prediction Model - Random Forest-based prediction system for forecasting AQI
- Hardware Integration - Raspberry Pi 5 with sensors for real-time data collection
- Real-time AQI monitoring for Delhi NCR
- Location-based air quality information
- Health advisories based on current AQI
- Visual smog representation based on pollution levels
- 3-day AQI predictions using machine learning
- User-friendly, elegant UI with intuitive navigation
- Random Forest regression model trained on multiple datasets
- Predictive analysis based on PM2.5, PM10, temperature, and humidity
- Flask API integration for real-time prediction serving
- Firebase database integration for data storage and retrieval
- Historical data analysis with interactive visualizations
- Raspberry Pi 5 integration with air quality sensors
- Real-time measurement of PM2.5, PM10, temperature, and humidity
- Data transmission to cloud database via Wi-Fi
- Web interface for monitoring sensor readings
- Low-power consumption design for continuous operation
![]() |
![]() |
![]() |
| Dashboard | Location Selection | Health Advisory |
Our AQI prediction model uses a Random Forest Regression approach trained on comprehensive datasets from multiple sources to predict air quality up to 3 days in advance.
- Inputs: PM2.5, PM10, temperature, humidity, wind speed, historical AQI trends
- Output: Predicted AQI values for the next 72 hours
- Accuracy: Achieves 87% prediction accuracy on test data
- Evaluation Metrics: RMSE, MAE, RΒ²
- Data collection from multiple sources
- Feature engineering and selection
- Outlier detection and handling
- Missing value imputation
- Normalization and scaling
- Model training and hyperparameter tuning
- Cross-validation and testing
The model is deployed as a Flask API that communicates with the mobile application through Firebase, enabling real-time predictions without excessive computational load on mobile devices.
- Raspberry Pi 5
- Nova PM SDS011 air quality sensor
- DHT22 temperature and humidity sensor
- Power supply and casing
- Connect the SDS011 sensor to USB port
- Connect the DHT22 sensor to GPIO pins
- Install required libraries:
pip install pyserial adafruit-dht - Clone this repository:
git clone https://github.com/RecursionReaper/ESP_9.git - Run the sensor collection script:
python sensor_data.py
The Raspberry Pi hosts a local web server that displays current sensor readings and provides a simple API for data retrieval. The web interface can be accessed by navigating to the Raspberry Pi's IP address in a web browser.
βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ
β Raspberry β β Firebase β β Flask API & β
β Pi Sensors βββββΆβ Database βββββΆβ ML Model β
βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ
β² β
β βΌ
βββββββββββββββββ βββββββββββββββββ
β Flutter Mobileββββββ Predicted β
β Application β β AQI Data β
βββββββββββββββββ βββββββββββββββββ
- Flutter/Dart
- Provider State Management
- Dio for API requests
- Firebase Integration
- Google Maps API
- Python 3.9+
- Scikit-learn for model development
- Pandas & NumPy for data manipulation
- Flask for API development
- Matplotlib & Seaborn for visualization
- Raspberry Pi OS
- Python for sensor integration
- Flask for web server
- MQTT for IoT communication
- Firebase Realtime Database
- Flutter SDK 3.0+
- Python 3.9+
- Firebase account
- Raspberry Pi with sensors (for hardware component)
-
Clone the repository
git clone https://github.com/RecursionReaper/ESP_9.git cd ESP_9/flutter_app -
Install dependencies
flutter pub get
-
Configure Firebase
- Add your
google-services.jsonfile to theandroid/appdirectory - Add your
GoogleService-Info.plistfile to theios/Runnerdirectory
- Add your
-
Run the app
flutter run
-
Navigate to the ML directory
cd ESP_9/ml_model -
Create and activate a virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Train the model
python train_model.py
-
Start the Flask API
python app.py
-
Navigate to the hardware directory
cd ESP_9/hardware -
Install dependencies
pip install -r requirements.txt
-
Run the data collection script
python sensor_data.py
Our system has been tested extensively for both prediction accuracy and system performance:
- RMSE: 14.617 AQI points
- MAE: 8.67 AQI points
- RΒ²: 0.995
- API response time: ~200ms
- Sensor data refresh rate: 30 seconds
- Mobile app battery consumption: <2% per hour
- Model retraining schedule: Weekly
The web interface provides a dashboard for monitoring real-time sensor data and system status. It features:
- Live AQI readings with time series graphs
- Temperature and humidity monitoring
- System health indicators
- Historical data access
- API status and logs
Access the web interface by navigating to the Raspberry Pi's IP address in a web browser.
- Expand to cover more locations across India
- Implement deep learning models for improved prediction accuracy
- Add notifications for dangerous AQI levels
- Develop IoT mesh network for distributed sensing
- Implement user accounts with personalized health recommendations
- Integrate with smart home systems for automated air purifier control
Our research into Delhi's air quality involved:
- Data collection from government monitoring stations, open data portals, and our own sensors
- Literature review of related work in AQI prediction and monitoring
- Feature engineering to identify key factors affecting air quality
- Model selection through comparative analysis of multiple algorithms
- Validation using historical data and real-time measurements
- User testing for application usability and feature validation
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Project Link: https://github.com/RecursionReaper/ESP_9
- Central Pollution Control Board for providing historical AQI data
- The Flutter and Python communities for excellent documentation and support
- Team members and advisors who contributed to this project
- Open-source libraries that made this project possible
Made with β€οΈ by Kartik Bulusu And Aniket Desai


