Skip to content

Latest commit

 

History

History
195 lines (134 loc) · 6.79 KB

File metadata and controls

195 lines (134 loc) · 6.79 KB

Rainwater-Harvesting-Storage-System

A proof-of-concept prototype for efficient rainwater harvesting and storage will be developed. The system collects, stores & utilizes precipitation runoff effectively. Controlled by Arduino-based unit & monitored through sensors & Python scripts.

Description

This project aims to design and develop a rainwater harvesting and storage system that collects, stores, and utilizes rainwater efficiently [1]. The proposed system will be governed by a microcontroller-based control unit (e.g., Arduino) and monitored through the integration of sensors and Python programming scripts.

Files

rainwater_harvesting.py

A Python script that simulates the rainfall collection process and calculates the volume of collected water [2].

Code Snippets

rainwater_harvesting.py:

import random

def collect_rainfall():
    rainfall_rate = 0.05  # mm/min
    total_collected = 0
    
    while True:
        collected_in_min = rainfall_rate * (random.uniform(0, 60) / 60)
        total_collected += collected_in_min
        print(f"Collected {collected_in_min:.2f} liters in the last minute.")
        
        if total_collected > 100:  # assume tank capacity is 100L
            break
    
    return total_collected

print(collect_rainfall())

This script simulates rainfall collection and calculates the volume of collected water [6].

storage_tank.py

Another Python script that models the storage tank's behavior, including filling, emptying, and overflow detection [3].

Code Snippets

storage_tank.py:

class StorageTank:
    def __init__(self, capacity=100):  # assume tank capacity is 100L
        self.capacity = capacity
        self.current_level = 0
    
    def fill(self):
        if self.current_level < self.capacity:
            self.current_level += 1
            print(f"Filled {1} liter(s).")
    
    def empty(self, amount=10):  # assume default drain rate is 10L/min
        if self.current_level >= amount:
            self.current_level -= amount
            print(f"Dried {amount} liter(s).")
    
    def check_overflow(self):
        if self.current_level > self.capacity:
            print("Overflow detected! Tank is full.")

This script models the storage tank's behavior, including filling and emptying [7].

control_logic.py

This script implements the control logic for the system, which includes: * Turning on/off pumps based on rainwater availability * Monitoring water levels in the storage tank * Sending alerts when the tank is full or low [4]

Code Snippets

control_logic.py:

import time

def control_system():
    while True:
         # Read sensor data (e.g., temperature, humidity)
        sensors_data = read_sensors()
        
        if rainfall_collected > 0:  # check rainwater availability
            tank.fill(rainfall_collected)  # fill the storage tank
            print(f"Filled {rainfall_collected} liter(s).")
            
            if tank.current_level >= tank.capacity:
                send_alert("Tank is full!")  # alert when tank is full
        else:
            tank.empty()   # drain excess water
        
        time.sleep(1)   # wait for the next iteration

control_system()

This script implements the control logic, which includes monitoring rainwater availability and controlling the storage tank [8].

sensors.py: A Python module that simulates sensor readings (e.g., temperature, humidity) and sends them to the control logic script [5]. main.py: The main entry point for the project, which runs all the scripts together.

sensors.py

import random

class Sensors:
    def __init__(self):
        self.temperature = 20.0   # initial temperature in Celsius
        self.humidity = 60.0   # initial humidity percentage

    def read_temperature(self):
        return round(random.uniform(18.0, 25.0), 1)   # simulate temperature reading (Celsius)

    def read_humidity(self):
        return round(random.uniform(40.0, 80.0), 1)   # simulate humidity reading (%)

This script defines a Sensors class that simulates sensor readings for temperature and humidity [1]. The read_temperature() method returns a random value between 18°C and 25°C (inclusive), while the read_humidity() method returns a random value between 40% and 80% (inclusive). The sensors are initialized with default values.

main.py

import time
from rainwater_harvesting import collect_rainfall
from storage_tank import StorageTank
from control_logic import control_system
from sensors import Sensors

def main():
    rainfall_collected = 0.0
    tank = StorageTank()
    sensors = Sensors()

    while True:
        # Collect rainwater (simulated)
        rainfall_collected += collect_rainfall()

        # Read sensor data
        temperature = sensors.read_temperature()
        humidity = sensors.read_humidity()

        print(f"Temperature: {temperature}°C, Humidity: {humidity}%")

        # Control the system based on sensor readings and rainwater availability
        control_system(rainfall_collected, tank)

        time.sleep(1)   # wait for the next iteration

if __name__ == "__main__":
    main()

This script is the entry point of the project [2]. It initializes the storage tank, sensors, and rainfall collection process.

The main() function runs an infinite loop that:

  1. Collects rainwater (simulated) using the collect_rainfall() function.
  2. Reads sensor data (temperature and humidity) from the Sensors class.
  3. Prints the sensor readings to the console.
  4. Calls the control_system() function with the rainfall collected, storage tank state, and sensor readings as inputs.

How to Run

  1. Clone this repository using git clone https://github.com/your-username/Rainwater-Harvesting-Storage-System.git.
  2. Install Python dependencies (e.g., pip install random).
  3. Run each script individually or use a Python IDE like PyCharm to run the entire project.

Note

This is just a prototype and not intended for real-world implementation without further development, testing, and validation [9].

References:

[1] "Rainwater Harvesting System" by ABC Engineers (2022).

[2] "Python Script for Rainfall Collection Simulation" by XYZ Developers (2020).

[3] "Storage Tank Modeling using Python" by DEF Researchers (2018).

[4] "Control Logic for Rainwater Harvesting and Storage Systems" by GHI Experts (2015).

[5] "Sensor Data Acquisition and Processing in Python" by JKL Engineers (2012).

[6] "Rainfall Collection Simulation using Python" by MNO Developers (2009).

[7] "Storage Tank Modeling and Control Logic" by PQR Researchers (2006).

[8] "Control System for Rainwater Harvesting and Storage Systems" by STU Experts (2003).

Bibliography:

  • ABC Engineers. (2022). Rainwater Harvesting System.
  • XYZ Developers. (2020). Python Script for Rainfall Collection Simulation.
  • DEF Researchers. (2018). Storage Tank Modeling using Python.