Rain Sensor with Arduino UNO

Introduction
The Rain Sensor is a simple and effective sensor used to detect the presence and intensity of rain. It is commonly used in weather monitoring systems, automatic wiper systems, smart irrigation projects, and home automation applications.
In this tutorial, you will learn how to interface a Rain Sensor with an Arduino UNO, upload the code, and monitor rain detection status using the Serial Monitor. By the end of this guide, you'll understand how to detect rainfall and moisture on the sensor plate using Arduino.
Components Required
Tools Required
Software Required
| Item Name | Action |
|---|---|
Arduio IDE | Download |
Circuit Diagram
Source Code
const int rainSensorPin = 2;
void setup()
{
pinMode(rainSensorPin, INPUT);
Serial.begin(9600);
}
void loop()
{
int rainState = digitalRead(rainSensorPin);
if(rainState == LOW)
{
Serial.println("Rain Detected");
}
else
{
Serial.println("No Rain");
}
delay(1000);
}Step by Step Instructions
Step 1: Connect the Rain Sensor
Make the following connections:
Rain Sensor | Arduino UNO |
|---|---|
VCC | 5V |
GND | GND |
DO | D2 |
Step 2: Open Arduino IDE
Launch Arduino IDE.
Connect Arduino UNO using USB.
Select:
Board → Arduino UNO
Port → Correct COM Port
Step 3: Create a New Sketch
Create a new Arduino sketch and paste the provided code.
Step 4: Verify the Code
Click the Verify button to check for syntax errors.
Step 5: Upload the Code
Click Upload and wait until the upload process completes successfully.
Step 6: Open Serial Monitor
Open Serial Monitor.
Set the baud rate to 9600.
Touch the sensor plate with a wet finger or sprinkle a few drops of water on it.
Observe the detection messages.
The Serial Monitor will display the rain detection status.
Expected Output
When the sensor is dry:
No Rain
No Rain
No RainWhen water is detected:
Rain Detected
Rain Detected
Rain DetectedConclusion
In this tutorial, you learned how to interface a Rain Sensor with Arduino UNO and detect the presence of water using digital input. This setup can be used in weather monitoring stations, automatic irrigation systems, rain alarm projects, and various environmental monitoring applications.









