Introduction
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.
Parts
- 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.
Connection:
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,
Negative pin = Gnd.
Step 3: Connection from Buzzer to Arduino Mega 2560.
Negative pin = Gnd
Programming:
- #define Grove_Water_Sensor 13 //Attach Water sensor to Arduino Digital Pin 13
- #define Grove_Piezo_Buzzer 10 //Attach Piezo Buzzer to Arduino Digital Pin 10
- #define LED 12 //Attach an LED to Digital Pin 12 (or use onboard LED)
- void setup(){
- pinMode(Grove_Water_Sensor, INPUT);
- pinMode(Grove_Piezo_Buzzer, OUTPUT);
- pinMode(LED, OUTPUT);
- }
-
- void loop()
- {
- if(digitalRead(Grove_Water_Sensor) == LOW){
- digitalWrite(LED,HIGH);
- digitalWrite(Grove_Piezo_Buzzer, HIGH);
- delay(2);
- digitalWrite(Grove_Piezo_Buzzer, LOW);
- delay(40);
- }
- else
- {
- digitalWrite(Grove_Piezo_Buzzer, LOW);
- digitalWrite(LED,LOW);
- }
- }
Explanation:
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 OFF. It can be used in to detect a leak, spill, flood, rain, etc.
Read more articles on Arduino: