Identifying Water Leaks Using Arduino Mega


In this article I will explain about identifying water leaks using Arduino Mega 2560. It will produce a sound and LED will turn ON if the water is leaking.
  • Arduino Mega 2560
  • Water Level Sensor
  • HookUp Wires 
  • Buzzer
  • LED
Water level Sensor:
It will sense the water leak; it can be used to identify the water leakage and also senses the water level. 
Step 1: Connection from the sensor to the Arduino Mega 2560,
  • Connected the Input pin of the sensor to the digital pin 13 of Arduino Mega 2560.
  • Connected the Vcc of sensor to the 5v of the Arduino Mega 2560.
  • Connected the Gnd of sensor to the Gnd of the Arduino Mega 2560. 
Step 2: Connection from LED to ArduinoMega2560,
Positive pin = 12
Negative pin = Gnd.
Step 3: Connection from Buzzer to Arduino Mega 2560.
Positive pin = 10 
Negative pin = Gnd
  1. #define Grove_Water_Sensor 13     //Attach Water sensor to Arduino Digital Pin 13  
  2. #define Grove_Piezo_Buzzer 10    //Attach Piezo Buzzer to Arduino Digital Pin 10  
  3. #define LED 12                   //Attach an LED to Digital Pin 12 (or use onboard LED)  
  4. void setup(){  
  5.  pinMode(Grove_Water_Sensor, INPUT);     //The Water Sensor is an Input  
  6.  pinMode(Grove_Piezo_Buzzer, OUTPUT);    //The Piezo Buzzer is an Output  
  7.  pinMode(LED, OUTPUT);                   //The LED is an Output  
  8. }  
  10. void loop()  
  11. {  
  12.  if(digitalRead(Grove_Water_Sensor) == LOW){  
  13.  digitalWrite(LED,HIGH);  
  14.  digitalWrite(Grove_Piezo_Buzzer, HIGH);  
  15.  delay(2);  
  16.  digitalWrite(Grove_Piezo_Buzzer, LOW);  
  17.  delay(40);  
  18.  }  
  19. else  
  20. {  
  21.    digitalWrite(Grove_Piezo_Buzzer, LOW);  
  22.    digitalWrite(LED,LOW);  
  23. }  
  24. }  
When the water leak it will automatically produce sound and LED also turns ON. When the water is not leaking it will not produce any sound and LED remains the same i.e OFFIt can be used in to detect a leak, spill, flood, rain, etc.
Read more articles on Arduino:

Recommended Ebook

Printing in C# Made Easy

Download Now!
Similar Articles