Detect Rain with Rain Sensor Module

Detect Rain with Rain Sensor Module

Objective

This experiment uses a rain sensor module to detect the presence of rain.

Required Components

Working Principle

The rain sensor detects rain by measuring the change in resistance when water falls on the sensor’s surface.

Circuit Diagram

Rain Sensor Circuit Diagram

Arduino Code


/*
 * Detect Rain with Rain Sensor Module
 * This code reads the rain sensor data and prints the result.
 */

const int rainPin = 2;  // Rain sensor connected to digital pin 2
int rainState = 0;

void setup() {
    pinMode(rainPin, INPUT);
    Serial.begin(9600);  // Initialize serial communication
}

void loop() {
    rainState = digitalRead(rainPin);  // Read the sensor value
    if (rainState == HIGH) {
        Serial.println("Rain Detected");
    } else {
        Serial.println("No Rain");
    }
    delay(1000);  // Wait for 1 second before the next reading
}
            

Results

The serial monitor will display either "Rain Detected" or "No Rain" based on the sensor's input.

Applications

Conclusion

The rain sensor module provides a simple and effective way to detect rain, making it useful for weather monitoring and smart irrigation systems.