MD R. Islam
Published © Apache-2.0

Water Waste Monitor

Millions of gallons of water are wasted every year. Learn to conserve water with this project!

BeginnerFull instructions provided30 minutes5,226

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Base Shield V2
Seeed Studio Base Shield V2
×1
Seeed Studio Groove - Sound Sensor
×1
Seeed Studio Grove - LCD RGB Backlight
×1
Seeed Studio Grove - Buzzer
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Fritzing sketch

Open in fritzing, use mic sensor instead of what's shown

Code

Arduino Seeed Sensor Code

Arduino
#include <Wire.h>
#include "rgb_lcd.h"

rgb_lcd lcd;

const int wasteColorR = 255;
const int wasteColorG = 0;
const int wasteColorB = 0;
const int restColorR = 255;
const int restColorG = 255;
const int restColorB = 255;


const int pinSound = A0;
const int pinLed   = 7;
const int speakerPin = 3;

int thresholdValue = 450;  // determines loudness for sound sensor
const unsigned long waterUseAllowedDuration = 3000;  // how long you want to use water for before warning

bool monitoring = false;

void playTone(int tone, int duration) {
    for (long i = 0; i < duration * 1000L; i += tone * 2) {
        digitalWrite(speakerPin, HIGH);
        delayMicroseconds(tone);
        digitalWrite(speakerPin, LOW);
        delayMicroseconds(tone);
    }
}

void setup() 
{
    pinMode(pinLed, OUTPUT);
    // set up the LCD's number of columns and rows:
    lcd.begin(16, 2);
    
    lcd.setRGB(restColorR, restColorG, restColorB);
    lcd.setCursor(0, 0);
    lcd.print("Water conserved     ");
    delay(1000);
}

void loop() 
{
    int sensorValue = analogRead(pinSound);
    if (sensorValue > thresholdValue) {
      lcd.setCursor(0, 0);
      lcd.setRGB(255, 251, 140);
      lcd.print("Monitoring use  ");
      delay(waterUseAllowedDuration);
      if (analogRead(pinSound) > thresholdValue - 200) {
        lcd.setRGB(wasteColorR, wasteColorG, wasteColorB);
        lcd.setCursor(0, 0);
        lcd.print("Excess water use");
        lcd.setCursor(0, 1);
        lcd.print("Try to conserve water");
        playTone(1700, 1000);
        delay(5000);
        lcd.clear();
      }
    } else {
      lcd.setRGB(restColorR, restColorG, restColorB);
      lcd.setCursor(0, 0);
      lcd.print("Water conserved");
    }
}

Credits

MD R. Islam

MD R. Islam

7 projects • 13 followers
software engineer

Comments