How to Make an Arduino Water Detection Alarm

This lesson will explain how to make a simple water detection alarm using an Arduino.

Breadboard Layout:
Combined_Speaker_WaterDetector_bb_OP

Arduino Code for Simple Water Detection Circuit:

/*Make a tone on your Arduino using an external 8-Ohm speaker
 
YOU WILL NEED:
  8-ohm speaker
  100-Ohm Resistor
  2 jumper wires / 2 alligator clips
  
CIRCUIT:
  100 Ohm resistor connected Arduino Pin 8
  Other side of resistor connected to the positive terminal of the speaker
  Negative terminal of the speaker connected to Ground
  
This code is in the public domain
  
*/


void setup() {
  
  pinMode(8, OUTPUT); //The Speaker is attached at this pin

}//close setup

void loop() {
  
  //Tone takes three arguments tone(pin, frequency, duration) 
  tone(8, 2000, 1000);
  
  //The loop does not wait for the tone to finish, so lets delay to here 2 seconds to hear
  //one second of noise and one second of silence - essentially a beep
  delay(2000);
  
}//Close Loop

installing Arduino libraries

Installing Arduino Libraries | Beginners Guide

IoT sewage project

Pumping poo! An IoT sewage project

ESP32 webOTA updates

How to update ESP32 firmware using web OTA [Guide + Code]

error message Brackets Thumbnail V1

expected declaration before ‘}’ token [SOLVED]

Compilation SOLVED | 1

Compilation error: expected ‘;’ before [SOLVED]

Learn how to structure your code

10 Comments

  1. James Seiwert on June 12, 2015 at 4:50 pm

    If it tells you when there is water, it should also let you know when there is no water by reversing the button code. Is this statment correct?

  2. Greg Webster on March 7, 2016 at 11:58 pm

    This is really bad. This circuit can’t overcome the resistance of water. I suspect you didn’t try this.

    • tweeksdisqus on November 12, 2017 at 10:06 am

      It depends..

      Condensed water (from an AC unit for example) will not conduct immediately.. however it’s also a solvent and will partially break down any metals it comes in contact with and eventually conduct. One “solution” (pardon the pun) would be to put some salt between your leads. This would make the puddle conductive.. and after drying out would stop conducting.. and the next water puddle (if not fully washed away) would conduct again. You might need to occasionally replenish this consumable.

      For me.. I’m measuring well water and ground water leaking in from the ground.. so mine would be hard already, and so conductive.

  3. Aditi Jain on March 15, 2017 at 12:00 pm

    Why is the 10k ohm resistor used?

    • Jayden Lawson on April 19, 2017 at 5:49 pm

      On the YouTube video, this question was asked, and the answer was “Because the current would be so high and will probably burn the speaker but when a resistor is added the current decrease”

  4. Michael Faux on April 20, 2017 at 4:47 pm

    My dad used to have a water detector that was kind of expensive, but one time use, making me think there was some material that dissolved, triggering a loss of material alarm. Or a conductive material that melts or dissolves in water.

  5. tweeksdisqus on November 12, 2017 at 10:09 am

    You’ll also want to define pin2 as in INPUT.

  6. Jane Iyer on September 2, 2020 at 10:05 am

    Whenever I try to conduct the water, it doesn’t detect it. But, it detects when I touch metal. How can I make it so that it will detect water properly?

    • Wendell509 on March 17, 2021 at 7:12 am

      same situation here

Leave a Comment