Arduino Rain Detector and Alarm Project

Arduino Rain Detector and Alarm Project

In this project, we are making an Arduino Rain Detector and Alarm System. It protects your electronic appliances outside your house from short-circuiting and damage by turning them off automatically when rain begins to fall. Because it only uses a few components, this circuit is simple, practical, and inexpensive. It doesn’t require much power and can easily run on 5 volts DC.

 

Components Required  for the Arduino Rain Detector and Alarm Project

Arduino Uno× 1Amazon
Rain Sensor Module× 1Amazon
Buzzer× 1Amazon
Breadboard× 1Amazon
Jumper wires× 2Amazon
USB cable type A/B× 1Amazon

Software

Arduino IDE

Rain Drop Sensor

Rain Drop Sensor is a simple rain detection tool. It is made up of two modules: a rain board that detects rain and a control module that compares and converts the analog value to a digital value. When a raindrop falls through the rainy board, it can be utilized as a switch, as well as to measure rainfall intensity. The Rain Drop Sensor Module has both digital and analog output pins and can be powered with +5V.

The Rain drops module also includes an LED to indicate the sensor’s output status and a potentiometer to control the sensor’s sensitivity. Based on the amount of water present on the detection plate, the analog pin produces analog voltage. It is used in the automation of tasks such as windshield wipers, automatic window closing in the event of a thunderstorm, or adjusting room temperature, as well as in the agriculture sector to plan crop watering.

When there is no rain or water on the detection plate, the digital pin will remain high. When a small amount of water is detected, the digital pin goes low and stays that way until the water is removed.

How Rain Sensor Module Works

The rain sensor board functions as a variable resistor, changing from 100K when wet to 2M when dry. More current flows through the board when it is wet. Two PCB tracks run through the Rain Sensor plate. These tracks aren’t linked together. The resistance between tracks changes when water falls on the plate or board.

The opamp measures the resistance. The analog voltage output is LOW when there is more water (lower resistance). Conversely, if the amount of water is less (higher resistance), the analog output voltage is HIGH. A dry rain board produces a 5V analog output.

The LED turns on when power is applied to the module. The digital output remains LOW when there is no raindrop. When water is detected, the digital output drops to a HIGH level and the switch indicator turns ON.

Note: In some Rain Sensor Module, The digital output remains HIGH when there is no raindrop. When water is detected, the digital output drops to a LOW level and the switch indicator turns ON.

So It’s best to check your rain sensor module’s datasheet or test your module to determine the digital output when water is detected.

Preset (Trimmer pot)

Using the onboard preset, you can adjust the digital output threshold (sensitivity).

Rain Sensor FEATURES

  1. Adopts high quality of the RF-04 double-sided material
  2. Area: 5cm x 4cm nickel plate on side
  3. Anti-oxidation, anti-conductivity, with long use time
  4. Comparator output signal clean waveform is good, driving ability, over 15mA
  5. Potentiometer adjust the sensitivity
  6. Working voltage 5V
  7. Output format: Digital switching output (0 and 1) and analog voltage output AO
  8. Small board PCB size: 3.2cm x 1.4cm
  9. Uses a wide voltage LM393 comparator
  10. Good for weather monitoring
  11. AO: Analog signal output
  12. DO: TTL switch signal output

Rain Sensor Applications

  1. Rain detection
  2. Weather monitoring
  3. Intelligent Agriculture
  4. Home Automation projects
  5. Rainfall intensity monitoring
  6. Windscreen of car to automatically start the wipers
  7. On roof of houses and offices to take necessary action against rain
  8. On the roof of houses and offices to take necessary action during rain
  9. It’s used in an irrigation system to automatically turn off the watering system when rain begins to fall.

Rain Sensor Specifications

Operating Voltage3.3-5V DC
Operating Current15mA
Comparator chipLM393
SensitivityAdjustable via Trimpot
Output typeAnalog output voltage (AO) and Digital switching voltage (DO)
LED lights indicatorsPower (red/green) and Output (red/green)
Sensing pad5cm x 4 cm nickel plate on one side.
Module PCB Size3.2cm x 1.4cm
Cost Check Price

For more information, you can check out the Rain Sensor Datasheet below:

Arduino Rain Detector Circuit Diagram

Arduino Rain Detector Circuit Diagram
Arduino Rain Detector Circuit Diagram

The rain sensor’s A0 pin connects to the analog pin A0 and D0 connects to the digital pin 2.

Arduino Rain Detector Code

By clicking the button in the top right corner of the code field, you can copy the code. Copy and paste it into Arduino IDE. 

/*** www.arduinopoint.com ***/
/*** Arduino Rain Detector Project***/

int rainAnalogPin = A0;
int rainDigitalPin = 2;

void setup(){
  pinMode(rainAnalogPin, INPUT);
  pinMode(rainDigitalPin, INPUT);
  Serial.begin(9600);
}

void loop() {
  // read the input on analog pin 0:
  int sensorAnalogValue = analogRead(rainAnalogPin);
  Serial.print("Rain sensor analog value: ");
  Serial.println(sensorAnalogValue);
  
  // read the input on digital pin 2:
  int sensorDigitalValue = digitalRead(rainDigitalPin);
  Serial.print("Rain sensor digital value: ");
  Serial.println(sensorDigitalValue);
  
//digital output
 if(sensorDigitalValue == HIGH) //High means rain detected; In some case vise versa
 {
 Serial.println("Rain Detected");
 }
 else {
 Serial.println("No Rain Detected");
 }
 delay(250);
}

Arduino Rain Alarm Circuit Diagram

Arduino Rain Alarm Circuit Diagram
Arduino Rain Alarm Circuit Diagram

LED and Buzzer connect to the digital pin 3 and 5 respectively.

Arduino Rain Alarm Code

/*** www.arduinopoint.com ***/
/*** Arduino Rain Alarm Project***/

int rainAnalogPin = A0;
int rainDigitalPin = 2;
int redLED = 3;
int alarm = 5; //PWM (~) Pin

void setup(){
  pinMode(rainAnalogPin, INPUT);
  pinMode(rainDigitalPin, INPUT);
  pinMode(alarm, OUTPUT);
  pinMode(redLED, OUTPUT);
  digitalWrite(alarm, LOW);
  digitalWrite(redLED, LOW);
  Serial.begin(9600);
}

void loop() {
  // read the input on analog pin 0:
  int sensorAnalogValue = analogRead(rainAnalogPin);
  Serial.print("Rain sensor analog value: ");
  Serial.println(sensorAnalogValue);
  
  // read the input on digital pin 2:
  int sensorDigitalValue = digitalRead(rainDigitalPin);
  Serial.print("Rain sensor digital value: ");
  Serial.println(sensorDigitalValue);
  
//digital output
 if(sensorDigitalValue == HIGH) //High means rain detected; In some case vise versa
 {
  digitalWrite(redLED, HIGH);
  tone(alarm, 5000); //the buzzer sound frequency at 5000 Hz
  Serial.println("Rain Detected");
 }
 else {
  digitalWrite(redLED, LOW);
  noTone(alarm);
  Serial.println("No Rain Detected");
 }
 delay(250);
}



Result

 You should see the rain detection message in your serial monitor. If you cannot see the desired output, ensure the circuit has been properly assembled, and verified and uploaded the code to your board.

Applications:
  1. Make Rain Detection, Rain Alarm, and Weather monitoring System.
  2. You can make a automatic windshield wipers.
  3. Make a irrigation system and acts as a water conservation device, shutting down the system in the event of rain.
  4. You can make a automated system to protect the interior parts of a car from rain as well as to support the regular windscreen wiper mode.

This Post Has One Comment

  1. Prohexal

    Heya i am for the first time here. I came across this board and I find It truly useful & it helped me out much. I hope to give something back and aid others like you aided me.

Leave a Reply