RainDrop Detection Using Arduino Uno

Introduction

 
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 raindrops and some other applications. The Rain Module Sensor Sense the following conditions based upon the temperature, irrigation, raindrops, etc.
 
There are two main applications for Rain Sensor
  • Water Conservation device connected to an automatic irrigation system.
  • Protect the interior of an automobile from rain. 
Requirements
  • Arduino Uno
  • Rain Sensor Module
  • Bread Board
  • Led
Connection
 
 
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 
 
Coding:
  1. int RainSensor=0;      
  2. int Alert=7;      
  3. int led=13;      
  4. int count=0;      
  5. void setup()      
  6. {      
  7.         
  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);      
  18.         
  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. }    
Explanation
 
Declare the variables
  • Rainsensor
  • Alert
  • led
  • Count as integer datatype and Initialize the value to the variables i,e analog pin and digital pin.
Functions
 
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 upon our condition the Rain Sensor will work.
 
It reads the Analog Pin value I,e Rain sensor value and then prints the sense the value that has 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 a 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).
 
Applications
  • Condensation Sensing
  • Irrigation Control
  • Drop Detection
Read more articles on Arduino: