RainDrop Detection Using Arduino Uno


In my previous article I explained about soil moisture sensor to sense irrigation and in this article I'll show you working with Rain Sensor to sense rain drops and some other applications. The Rain Module Sensor Sense the following conditions based up on the temperature, irrigation, rain drops etc.
There are two main applications for Rain Sensor
  • Water Conservation device connected to an automatic irrigation system.
  • Protect the interior of an auto-mobile from rain. 
  • Arduino Uno
  • Rain Sensor Module
  • Bread Board
  • Led

                                 Figure: Rain Sensor
  • Analog pin to Arduino A0
  • Gnd to Gnd
  • Vcc to 5v
Led Connection:
  • Anode pin to the Arduino digital pin13
  • Cathode pin to the Gnd 

  1. int RainSensor=0;    
  2. int Alert=7;    
  3. int led=13;    
  4. int count=0;    
  5. void setup()    
  6. {    
  8.   Serial.begin(9600);    
  9.   pinMode(Alert,OUTPUT);    
  10.   pinMode(RainSensor,INPUT);    
  11.   pinMode(led,OUTPUT);    
  12. }    
  13. void loop()    
  14. {    
  15.   int Sense=analogRead(RainSensor);    
  16.   Serial.println(Sense);    
  17.   delay(100);    
  19.   if(count >=44){    
  20.     digitalWrite(led,HIGH);    
  21.     digitalWrite(Alert,HIGH);    
  22.   }    
  23.   while(Sense < 400){    
  24.     count++;    
  25.   }    
  26.   do{    
  27.     digitalWrite(led,LOW);    
  28.     digitalWrite(Alert,LOW);    
  29.     count=0;    
  30.   }while(Sense > 400);    
  31.   delay(1000);    
  32. }   

Declare the variables
  • Rainsensor
  • Alert
  • led
  • Count as integer datatype and Initialize the value to the variables i,e analog pin and digital pin.

Void setup()
  • Set the PinMode as OUTPUT and INPUT
  • Set the BaudRate (9600)
Void loop()

The loop function is the one type of the condition function based up on our condition the Rain Sensor will work.

It reads the Analog Pin value i,e Rain sensor value and then print the sense the value that have been sensed by the rain sensor and make the condition to the count value if ( count >=44) the led will ON and the alert will be HIGH while (sense <400) and increment the count value using ++ operator then do the led will goes LOW and alert also LOW while (sense>400) and set the delay time (1000).

  • Condensation Sensing
  • Irrigation Control
  • Drop Detection
Read more articles on Arduino:

Up Next
    Ebook Download
    View all
    View all