Mini-Project Final Review/Exam Writeup
Title of the Project:
IoT-Based Water Quality Monitoring System Using Flask and MongoDB
Abstract:
1. This project focuses on real-time water quality monitoring using IoT
sensors and a web-based dashboard.
2. Sensor data is collected via a microcontroller and transmitted to a
computer through serial communication.
3. The collected data is stored in a MongoDB database for processing and
analysis.
4. A Flask web server is used to compute water quality index (WQI) and
provide visual insights.
5. The system categorizes water quality based on WQI into different usability
levels.
6. The database is maintained with a rolling window of 50 records to ensure
recent data is always available.
7. The system allows remote monitoring of water quality via a web interface.
8. It supports multiple parameters such as pH, temperature, turbidity, and
dissolved oxygen (DO).
9. The web application provides an easy-to-understand JSON output for
integration with other systems.
10.The project is an efficient and cost-effective solution for real-time water
quality analysis.
Objective:
1. To develop a real-time water quality monitoring system using IoT.
2. To collect sensor data and store it in a MongoDB database.
3. To compute parameter averages and calculate Water Quality Index (WQI).
4. To classify water quality into different usability categories.
5. To provide a web-based interface for easy visualization of data.
6. To ensure a rolling database of the last 50 sensor readings for analysis.
7. To use Flask for backend processing and API-based data retrieval.
8. To improve environmental monitoring and public health safety.
9. To develop a scalable and extensible system for future enhancements.
10.To minimize manual water testing efforts by automating the process.
Components Required:
1. Hardware:
o Microcontroller (Arduino/ESP8266)
o pH sensor
o Turbidity sensor
o Temperature sensor
o Total Dissolved Solids (TDS) sensor
o Dissolved Oxygen (DO) sensor
o Nitrate sensor
o Electrical Conductivity (EC) sensor
o Serial USB cable
o Power supply
2. Software:
o Python (Flask, PyMongo)
o MongoDB for database storage
o Arduino IDE (for sensor integration)
o HTML/CSS for web interface (optional)
o JSON format for data exchange
o Statistics library for data processing
Block Diagram:
1. Sensors collect real-time water quality data.
2. Data is sent to the microcontroller.
3. Microcontroller transmits data to the computer via serial
communication.
4. Python script (senddb.py) reads the data and stores it in
MongoDB.
5. Flask web server (server.py) fetches the latest readings from
MongoDB.
6. Flask calculates averages and Water Quality Index (WQI).
7. Processed data is sent to the web dashboard or API endpoint.
8. User accesses water quality insights through a web interface.
9. A database clearing mechanism ensures only recent data is kept.
10.Data can be further analyzed for trends and reports.
Explanation:
1. Sensors collect real-time water quality data, including pH, temperature,
TDS, and more.
2. The microcontroller reads the sensor values and transmits them via serial
communication.
3. A Python script (senddb.py) reads incoming serial data and inserts it into
MongoDB.
4. MongoDB stores up to 50 records, deleting the oldest when new data
arrives.
5. Flask-based web server (server.py) fetches the latest data and calculates
parameter averages.
6. The Water Quality Index (WQI) is computed using predefined weights and
limits.
7. The system classifies water quality into different usability levels based on
WQI.
8. A web API (/data) returns the processed data in JSON format.
9. A frontend interface can be used to visualize water quality trends.
10.Users can clear the database manually via an API (/clear-database).
Methodology:
1. Setup Sensors: Connect pH, turbidity, and other sensors to the
microcontroller.
2. Establish Serial Communication: Configure baud rate and port settings
for real-time data transfer.
3. Data Collection & Storage: Use MongoDB to store up to 50 latest
sensor readings.
4. Web Server Development: Implement Flask API to serve data and
compute WQI.
5. Computation of WQI: Use weighted parameters to determine water
quality levels.
6. Data Processing: Filter out noise, compute averages, and check for
missing values.
7. User Interface Development: Display real-time water quality data using
Flask or a dashboard.
8. Testing & Debugging: Ensure accurate sensor readings and proper
database updates.
9. Optimization: Implement error handling, database clearing, and
performance enhancements.
10.Deployment: Run the system continuously for real-time monitoring and
alerting.
Conclusion:
1. The project successfully monitors water quality using IoT-based sensors.
2. It provides real-time data visualization and analysis using Flask and
MongoDB.
3. The system automatically calculates Water Quality Index (WQI) for easy
interpretation.
4. A rolling database of 50 records ensures recent and relevant data is
maintained.
5. The web interface/API allows remote monitoring of water parameters.
6. The project minimizes manual intervention in water testing.
7. The system is scalable and can integrate additional sensors if required.
8. It helps in identifying polluted water sources for timely corrective actions.
9. This approach enhances environmental monitoring and public health
safety.
10.Future improvements can include machine learning for predictive analysis.
Advantages:
1. Real-time Monitoring: Provides instant water quality updates.
2. Automated Data Processing: Eliminates the need for manual
calculations.
3. Remote Access: Web-based API allows easy monitoring from anywhere.
4. Cost-Effective: Uses affordable sensors and open-source software.
5. Scalability: Can accommodate more sensors and parameters in the
future.
6. Database Management: Automatically deletes old records to maintain
efficiency.
7. Water Quality Index (WQI): Provides an easy-to-understand quality
classification.
8. User-Friendly API: JSON-based output for seamless integration.
9. Environmental Impact: Helps in pollution monitoring and control.
10.Customizable: Parameter weights and limits can be adjusted as needed.
Disadvantages:
1. Sensor Accuracy: Low-cost sensors may have limited precision.
2. Limited Data Retention: Only 50 records are stored at a time.
3. Dependency on Serial Communication: Requires stable connectivity
for real-time updates.
4. Manual Database Clearing: Users need to clear the database if
required.
5. Limited Web Interface: Lacks an advanced graphical representation of
data.
6. Environmental Variability: Factors like temperature and turbidity affect
sensor accuracy.
7. Power Consumption: Sensors and microcontrollers require a continuous
power supply.
8. Limited Predictive Capabilities: The system does not predict future
water quality trends.
9. Lack of Mobile App Integration: Currently, no dedicated mobile
support.
10.Potential Latency: Real-time updates depend on hardware and network
efficiency.
Applications:
1. Drinking Water Monitoring: Ensures safe drinking water quality.
2. Industrial Water Treatment: Monitors water quality for industrial use.
3. Agricultural Irrigation: Helps in assessing water suitability for farming.
4. Aquaculture & Fisheries: Maintains optimal water conditions for fish
farming.
5. Environmental Monitoring: Tracks pollution levels in lakes and rivers.
6. Smart Cities: Integrates with urban water management systems.
7. Research & Development: Useful for studying water quality trends.
8. Educational Projects: Helps students learn about water quality
assessment.
9. Wastewater Treatment Plants: Monitors effluent discharge quality.
10.Disaster Response: Assesses water contamination during floods or
chemical spills.
This structured writeup provides a comprehensive review of the project, covering
all aspects from concept to application.