5 August 2014

Grove Water Sensor


Connecting a water sensor to an Arduino is a great way to detect a leak, spill, flood, rain etc. It can be used to detect the presence, level, volume and/or the absence of water. While this could be used to remind you to water your plants, there is a better Grove sensor for that. The sensor has an array of exposed traces which will read LOW when water is detected. In this tutorial, we will connect the Water Sensor to Digital Pin 8 on the Arduino, and will enlist the very handy Grove Piezo buzzer and an LED to help identify when the Water sensor comes into contact with a source of water.


 

Parts Required:

Putting it together


If you have a Grove Base Shield, you just have to connect the Grove Water Sensor to D8 on the shield, and the Buzzer to D12 on the Shield. My Grove base shield obstructs the onboard LED, so I will attach an LED to Digital pin 13. If you do not have a Grove base shield, then you should connect the Sensors as described in the tables below:
 


 

Arduino Sketch


 
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
    
    
/* 
  Grove Water Sensor sketch 
     Written by ScottC 5th August 2014
     Arduino IDE version 1.0.5
     Website: http://arduinobasics.blogspot.com
     Description: Use Grove Water Sensor to detect leaks, floods, spills, rain etc.
     Credits: This sketch was inspired by this website:
              http://www.seeedstudio.com/wiki/Grove_-_Water_Sensor     
 ------------------------------------------------------------- */
#define Grove_Water_Sensor 8     //Attach Water sensor to Arduino Digital Pin 8
#define Grove_Piezo_Buzzer 12    //Attach Piezo Buzzer to Arduino Digital Pin 12
#define LED 13                   //Attach an LED to Digital Pin 13 (or use onboard LED)
void setup(){
 pinMode(Grove_Water_Sensor, INPUT);     //The Water Sensor is an Input
 pinMode(Grove_Piezo_Buzzer, OUTPUT);    //The Piezo Buzzer is an Output
        pinMode(LED, OUTPUT);                   //The LED is an Output
}

void loop(){
        /* The water sensor will switch LOW when water is detected.
           Get the Arduino to illuminate the LED and activate the buzzer
           when water is detected, and switch both off when no water is present */
 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);
        }
}
    
    


 

The Video


 


If you liked this tutorial - please show your support :

10 comments:

  1. Good ..before nothing congratulate you on the web, I have learned many things in it. I would like to make an inquiry could utilzar the same skech but add a Grove Relay and this will activate when the water sensor is put into HIGH and when the sensor is put on LOW the relay is disconnected.

    That code would have to add, if someone could help me I would appreciate very much. I am new to this arduino and programming. I've tried many ways and nothing.

    Thank you

    ReplyDelete
    Replies
    1. I have a Grove Relay tutorial that may help you:
      http://arduinobasics.blogspot.com.au/2014/09/relay-module.html

      Delete
  2. does this thing actually work?

    ReplyDelete
    Replies
    1. Yes it does. Have a look at the video.

      Delete
  3. Syed Mohsin Hasan16 August 2016 at 17:42

    nice project! it worked with no problems

    ReplyDelete
    Replies
    1. Great to hear Syed ! Thanks for your feedback.

      Delete
  4. I possible to use this sensor to detect water content in the soil? I want to build simple watering device based on soil moisture. Here is an example of the device: http://daisy.si/

    ReplyDelete
    Replies
    1. No - this will not tell you the water content in the soil. The water bridges the contacts on the sensor and it will detect it. So any amount of water large or small, that bridges the gap, will trigger this sensor. I think there are other sensors that will do what you are looking to do. For example: this one.

      Delete
  5. Can I use grove water sensor without the grove base shield?

    ReplyDelete
    Replies
    1. Yes - of course. The Base shield just simplifies the connection. But you could just use female-to-male jumper wires.

      Delete

Feel free to leave a comment about this tutorial below.
Any questions about your particular project should be asked in the ArduinoBasics forum.

Comments are moderated due to large amount of spam.