Project 13

Water Level Detector - Arduino Uno

Project Description

The water detection system is designed to monitor moisture levels and activate an alarm response when water is detected beyond a set threshold. The sensor continuously measures the surrounding moisture value, and once the water level rises above the predefined threshold, the system immediately turns ON both the relay and the buzzer. This allows the relay to activate any connected device such as a pump, valve, or alert indicator while the buzzer provides an audible warning to signal the presence of water. When the water level drops below the threshold, the system automatically turns OFF the relay and silences the buzzer, returning to its normal standby state. This arrangement offers an efficient, real-time method of detecting leaks, flooding, or unwanted water presence, making it ideal for safety alarms, homes, industrial areas, and water management systems.

In this simple project, only levels above a certain point are of interest. This could be a flood warning system or a fill level sensor in a pumping system. The sensor itself can measure values continuously 

Components
  • Arduino Uno
  • Water sensor modoule
  • Jumper wires
  • Relay
  • Buzzer
  • Breadboard
  •  
Code

#include <Tone.h>

int waterSensor = A0;    // Water sensor analog pin
int relayPin = 8;        // Relay control pin
int threshold = 600;     // Adjust based on sensor readings

Tone buzzer;             // Create Tone object

void setup() {
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, LOW);  // Relay OFF initially
  buzzer.begin(9);              // Buzzer connected to pin 9
  Serial.begin(9600);
}

void loop() {
  int sensorValue = analogRead(waterSensor);
  Serial.print("Water Sensor Value: ");
  Serial.println(sensorValue);

  if (sensorValue > threshold) {
    // Water detected
    digitalWrite(relayPin, HIGH);

    // Play alert sound (frequency 1000 Hz)
    buzzer.play(1000, 500); // frequency, duration (ms)

    Serial.println("WATER DETECTED → Relay ON");
  } 
  else {
    // No water detected
    digitalWrite(relayPin, LOW);

    // Ensure buzzer is silent
    buzzer.stop();

    Serial.println("NO WATER → Relay OFF");
  }

  delay(500);
}

Taking things further
  • The relay can be used to control a pump to turn on or off
  • The data from the sensor can be transmitted wirelessly or displayed on an LCD screen