Arduino Rain Sensor Project

Last Updated on March 24, 2024

rain

This project explains how to interface rain sensor with arduino. It is very simple project as reading analog signal from sensor just one code like “analogRead“. But the applications of this project has widest possibilities.

The rain sensors available in different size and categories depends on sensing area and comparator module. So many online vendors are selling it with reasonable cost, just google it as rain sensor you will get best one.




The rain sensor uses FR-04 high quality double side materials for widest sensing, it uses LM393  low voltage comparator with output driving ability over 15mA. Operating voltage of this module varies between 3.3 volts to 5 Volts, best to give 5 V from Arduino power pins.

Rain Sensor Module

rain sensor

Hookup Guide

Connect the rain sensor and buzzer with arduino as shown in the hookup image, in this project we taken buzzer device as a alarm output device. You can choose any output device depends on your need, remember to change the arduino code as well 🙂

rain sensor hookup

Arduino Code for Rain Sensor

/*Arduino Rain Sensor sketch*/

int rainsense= 0; // analog sensor input pin 0
int buzzerout= 10; // digital output pin 10 - buzzer output
int countval= 0; // counter value starting from 0 and goes up by 1 every second
 
void setup(){
   Serial.begin(9600);
   pinMode(buzzerout, OUTPUT);
   pinMode(rainsense, INPUT);
}
void loop(){
   int rainSenseReading = analogRead(rainsense);
   Serial.println(rainSenseReading); // serial monitoring message 
   delay(250);// rain sensing value from 0 to 1023.
   // from heavy rain - no rain.
   if (countval >= 35){ 
      Serial.print("Heavy rain");
      digitalWrite(buzzerout, HIGH);  //raise an alert after x time
   }
   //raining for long duration rise buzzer sound
   // there is no rain then reset the counter value
   if (rainSenseReading <350){ 
      countval++; // increment count value
   }
   else if (rainSenseReading >350) { // if not raining
      digitalWrite(buzzerout, LOW); // turn off buzzer 
      countval = 0; // reset count to 0
   }
   delay(1000);
}

The rain sensor Analog output terminal is connected with arduino (A0) pin, and the output taken from digital pin D10 (Ooh! i have taken D11 as output in prototype B-).) the 5V and Gnd power source applied to the sensor module, when the rain falls the analog output varies from 5V to 0. If the sensor remains try then output will be 5V, you can invert this output voltage range using single transistor if you want. In this project we used serial monitor to just show the rain sensor reading you can introduce formulas or any thing you want to make it more informative.

Prototype

arduino rain prototype




4 thoughts on “Arduino Rain Sensor Project

  1. Hi,

    I interested in the rain detect project.
    Can I ask some question?
    when the rain stop, if there are water on the detecting bouard, the system will detect that it just water or it still raining? (My project is collect a rain water but it has to open the cover only when raining)

    thank you
    tanwa

Leave a Reply

Your email address will not be published. Required fields are marked *