How to build Rain alarm using Arduino

Arduino

How to build Rain sensor

We will use the below rain sensor and driver to build Rain alarm system. Sensor is 2 pin module just connect it with driver input pin. Driver module has 4 pin. We use pin-6 as data input from driver. Driver will provide low output in case rain fall on to sensor. Pin-9 use for driver power supply by setting high output

rainsensor-driver

Rain-sensor

Connectivity Diagram

Rain-Sensor-Connctivity

Program:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int D0 = 6;
const int powerrainsensor = 9;

void setup() {
// put your setup code here, to run once:

Serial.begin(9600);
pinMode(D0, INPUT);
pinMode(powerrainsensor, OUTPUT);
lcd.begin(16, 2);
lcd.print(” Rain Sensor”);
lcd.display();
digitalWrite(powerrainsensor, HIGH);
}

void loop() {

boolean rain;
rain = digitalRead(D0);
Serial.print(rain);
Serial.print(” Raining “);
Serial.println();

if(rain==false){
itsRaining();
}else{
itsNotRaining();
}
delay(1000);
}
void itsNotRaining(){
Serial.println(“Its Not Raining”);
lcd.noDisplay();
lcd.setCursor(0, 0);
lcd.print(“Its Not Raining”);
lcd.display();
}
void itsRaining(){
Serial.println(“Its Raining “);
lcd.noDisplay();
lcd.setCursor(0, 0);
lcd.print(“Its Raining”);
lcd.display();
}

For LCD Connectivity check the below link

How to add LCD with Arduino Uno Board

Run it and enjoy, below is the video tutorial for this project which can help you more