Skip to content

RecursionReaper/ESP_9

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Delhi AQI Prediction System

πŸ“Š Project Overview

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:

  1. Flutter Mobile Application - User-friendly interface for monitoring AQI levels
  2. ML Prediction Model - Random Forest-based prediction system for forecasting AQI
  3. Hardware Integration - Raspberry Pi 5 with sensors for real-time data collection

🌟 Features

Mobile Application

  • 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

ML Prediction System

  • 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

Hardware Sensors

  • 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

πŸ“± Mobile App Screenshots

Dashboard Location Selection Health Advisory
Dashboard Location Selection Health Advisory

🧠 ML Model Architecture

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.

Model Features

  • 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 Processing Pipeline

  1. Data collection from multiple sources
  2. Feature engineering and selection
  3. Outlier detection and handling
  4. Missing value imputation
  5. Normalization and scaling
  6. Model training and hyperparameter tuning
  7. Cross-validation and testing

API Integration

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.

πŸ”Œ Hardware Setup

Components

  • Raspberry Pi 5
  • Nova PM SDS011 air quality sensor
  • DHT22 temperature and humidity sensor
  • Power supply and casing

Setup Instructions

  1. Connect the SDS011 sensor to USB port
  2. Connect the DHT22 sensor to GPIO pins
  3. Install required libraries: pip install pyserial adafruit-dht
  4. Clone this repository: git clone https://github.com/RecursionReaper/ESP_9.git
  5. Run the sensor collection script: python sensor_data.py

Web Interface

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.

πŸ“Š Data Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Raspberry   β”‚    β”‚    Firebase   β”‚    β”‚  Flask API &  β”‚
β”‚  Pi Sensors   │───▢│   Database    │───▢│    ML Model   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β–²                    β”‚
                            β”‚                    β–Ό
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚ Flutter Mobile│◀───│   Predicted   β”‚
                     β”‚ Application   β”‚    β”‚   AQI Data    β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Technology Stack

Mobile Application

  • Flutter/Dart
  • Provider State Management
  • Dio for API requests
  • Firebase Integration
  • Google Maps API

Machine Learning

  • Python 3.9+
  • Scikit-learn for model development
  • Pandas & NumPy for data manipulation
  • Flask for API development
  • Matplotlib & Seaborn for visualization

Hardware & IoT

  • Raspberry Pi OS
  • Python for sensor integration
  • Flask for web server
  • MQTT for IoT communication
  • Firebase Realtime Database

πŸš€ Installation & Setup

Prerequisites

  • Flutter SDK 3.0+
  • Python 3.9+
  • Firebase account
  • Raspberry Pi with sensors (for hardware component)

Mobile App Setup

  1. Clone the repository

    git clone https://github.com/RecursionReaper/ESP_9.git
    cd ESP_9/flutter_app
  2. Install dependencies

    flutter pub get
  3. Configure Firebase

    • Add your google-services.json file to the android/app directory
    • Add your GoogleService-Info.plist file to the ios/Runner directory
  4. Run the app

    flutter run

ML Model Setup

  1. Navigate to the ML directory

    cd ESP_9/ml_model
  2. Create and activate a virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Train the model

    python train_model.py
  5. Start the Flask API

    python app.py

Hardware Setup

  1. Navigate to the hardware directory

    cd ESP_9/hardware
  2. Install dependencies

    pip install -r requirements.txt
  3. Run the data collection script

    python sensor_data.py

πŸ“ˆ Performance Analysis

Our system has been tested extensively for both prediction accuracy and system performance:

ML Model Accuracy

  • RMSE: 14.617 AQI points
  • MAE: 8.67 AQI points
  • RΒ²: 0.995

System Performance

  • API response time: ~200ms
  • Sensor data refresh rate: 30 seconds
  • Mobile app battery consumption: <2% per hour
  • Model retraining schedule: Weekly

🌐 Web Interface

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.

πŸ“‹ Future Enhancements

  • 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

πŸ” Research Methodology

Our research into Delhi's air quality involved:

  1. Data collection from government monitoring stations, open data portals, and our own sensors
  2. Literature review of related work in AQI prediction and monitoring
  3. Feature engineering to identify key factors affecting air quality
  4. Model selection through comparative analysis of multiple algorithms
  5. Validation using historical data and real-time measurements
  6. User testing for application usability and feature validation

πŸ‘₯ Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ž Contact

Project Link: https://github.com/RecursionReaper/ESP_9

πŸ™ Acknowledgments

  • 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors