Webdroid Edutech
Published

Rain Detection System Using Arduino

This project demonstrates how to build a rain detection system using an Arduino microcontroller.

BeginnerProtip3 hours152
Rain Detection System Using Arduino

Things used in this project

Hardware components

Arduino Uno
×1
5V Passive Buzzer
×1
7-12 V DC Battery (in our case lipo 2s battery)
×1
Jumper Wires
×1
Rain Sensor Module
×1

Story

Read more

Code

Code

Arduino
#define RAIN_SENSOR A0
#define BUZZER 9
 
void setup() {
    pinMode(RAIN_SENSOR, INPUT);
    pinMode(BUZZER, OUTPUT);
    Serial.begin(9600);
}
 
void loop() {
    int sensorValue = analogRead(RAIN_SENSOR);
    Serial.println(sensorValue);
    
    if (sensorValue < 102) { // Threshold for rain detection
        digitalWrite(BUZZER, HIGH);
    } else {
        digitalWrite(BUZZER, LOW);
    }
    delay(1000); // Delay for stability
}

Credits

Webdroid Edutech
12 projects • 2 followers
Contact

Comments

Please log in or sign up to comment.