Arduino Based Tap Leak Detector

by RasikaTheExplorer in Circuits > Arduino

3452 Views, 3 Favorites, 0 Comments

Arduino Based Tap Leak Detector

tap1.jpg

In locations suffering from acute water shortages, every drop of water counts. It really annoys me to see people not closing taps tightly enough after use, or neglecting repairs of leaking taps. After talking to many such people, I realized that most of them are conscious about water wastage, however, they just do not realize sometimes that they tap has not been closed tightly enough. If someone (or something) asks them to close the taps properly, they readily do so. This gave me an idea for my project- A DIY tap leak detector.

The premise of this project is simple. Taps are rarely left completely open for no reason. It is only problematic when water is wasted, despite being the tap closed. This could be due to two reasons:

  • Tap is not closed tightly enough, thus leaving a small stream of water flow.
  • Tap is closed but damaged, causing leaks

My DIY project detects whether there is any water flow from a CLOSED tap due to any of the above-mentioned reason, and rings an alarm to alert nearby people to look into the matter- whether it is simply a matter of closing the tap tightly or checking if any repairs are required.

Possible solutions:

I brainstormed 5 possible solutions to solve this problem

  • Leak detector using a water sensor (Selected)
  • Leak detector using water flow sensor (rejected because it may not be sensitive enough for the flow of dripping water)
  • Leak detector using a piezo sensor (rejected because it may not be sensitive enough for the pressure of dripping water)
  • Leak detector using water pressure sensor (rejected because requires internal changes in the plumbing system)
  • Leak detector using an acoustic sensor (rejected because other sounds may overpower the sounds of dripping water)

As a prototype, my project is applicable only for the taps with valves moving up and down.

Materials Used:

  1. Arduino Uno R3Ultrasonic Sensor ( HC-SR-04 Ultrasonic Sensor)
  2. Servo Motor (Tower Pro SG-90 9g Micro Servo Motor)
  3. Water Sensor (Water Level Sensor Module- RKI 2350)
  4. Jumper wires
  5. Breadboard
  6. LED
  7. Resistor

Cost of Project: Rs. 800 (approx.)

References:

For creating my prototype, I have referred to the following tutorials of components:

Setting Up the Ultrasonic Sensor

ultrasonic pic.JPG
IMG_20190503_101055.jpg
IMG_20190503_101043.jpg

First, I need to detect whether the tap is open or shut. This is important because I don't want to sense the obvious water flow when the tap is open. I used an ultrasonic sensor for this purpose.

Note that the ultrasonic sensor should be placed right in front of the tap valve's CLOSE position. I'm also using a red LED as an output. Thus, when the tap valve is in CLOSE position, the LED should be ON, whereas when the tap valve is in the OPEN position, the LED should be OFF.

How to set up-

The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo.

  • The Ground pin of the module needs to be connected to the Ground
  • The VCC pin is to be connected to the 5V pins on the Arduino Board
  • The trig pin is to be connected to Digital pin 3 on Arduino
  • The echo pin is to be connected to Digital pin 2 on Arduino
  • Furthermore, set connect the positive terminal of the LED to Digital pin 5 on Arduino. Complete the circuit with a resistor and connect to the Ground.

Setting Up the Servo Motor

serv.JPG
IMG_20190503_102042.jpg

Since I did not want to detect water flow when the tap is open, I decided to use a servo motor to move the water sensor out of the way, when the tap is open, and back in place when the tap is closed.

Following are the steps to connect a servo motor to the Arduino:
The servo motor has three pins.

  1. The darkest black one is usually the ground. Connect this to the Ground.
  2. Connect the power cable (usually red) to 5V on the Arduino.
  3. Connect the remaining line on the servo connector to a digital pin 4 on the Arduino.

Setting Up the Water Sensor and an Alert

IMG_20190503_144806.jpg
water sensor.JPG
IMG_20190503_101336.jpg
IMG_20190503_102111.jpg

The Water Sensor is attached to the servo motor. Do a little adjustment to make sure that the rotation of the servo motor actually moves the water sensor in and out of the way of the water flow.

How to set up the water sensor:

The water sensor has 3 pins:

  • Connect + pin to 5V pin on Arduino
  • Connect - pin to the Ground
  • Connect S pin to digital Pin 8 on Arduino

If a leak is detected by the water sensor, there needs to be an alarm to alert people nearby to look into the matter. For this purpose, I have simply used an LED. It may be substituted with a buzzer

  • Connect the black pin to the ground.
  • Connect the other pin to digital pin 6 of Arduino.

Code It on Arduino IDE

Overall.JPG
<p>//Arduino based tap Leak Detector</p><p>//Initializing Ultrasonic Sensor
const int trigPin = 3; // Trigger Pin of Ultrasonic Sensor
const int echoPin = 2; // Echo Pin of Ultrasonic Sensor
int redled = 5;</p><p>//Initializing Servo Motor
#include <servo.h>  
int servoPin = 4;
Servo servo;  
int servoAngle = 0;   // servo position in degrees
boolean flag=false;</servo.h></p><p>//Initializing Water Sensor
int water_sensor = 8;
int whiteled = 6;</p><p>void setup() 
{
  //Ultrasonic Sensor Setup
   pinMode(redled, OUTPUT);
   pinMode(trigPin, OUTPUT);
   pinMode(echoPin, INPUT);</p><p>  //Servo Motor Setup
   Serial.begin(9600);  
   servo.attach(servoPin);</p><p>  //Water Sensor
   pinMode(water_sensor, INPUT); // 
   pinMode(whiteled, OUTPUT); // 
}</p><p>void loop()
{ </p><p>long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;</p><p>if (distance < 10)</p><p>{ 
  digitalWrite(redled,HIGH);
  servo.write(135);  
}</p><p>else 
{
  digitalWrite(redled,LOW);
  servo.write(-135);
}</p><p>if(digitalRead(water_sensor) == LOW) 
  {digitalWrite(whiteled,HIGH);}
 else 
  {digitalWrite(whiteled,LOW);}</p><p>}</p>

Place the System on a Tap

All you need to ensure is that you-

1. Place the Ultrasonic Sensor in front of the CLOSED tap valve, such that the sensor detects the change between OPEN and CLOSE position.

2. Place the servo motor(and the attached water sensor), such that the rotation of the motor moves the water sensor in and out of the way of the water flow.

The project is READY! :)