Smart Rain Detector using Arduino
This project detects rain using a rain sensor and alerts the user using a buzzer and LED. It can also
be extended to automatically close windows or turn off irrigation systems.
Components Required:
1. Arduino Uno
2. Rain Sensor Module
3. Buzzer
4. LED
5. Resistor (220 ohm)
6. Jumper wires
7. Breadboard
Working Principle:
The rain sensor detects water droplets. When rain falls on the sensor, it changes resistance.
Arduino reads this signal and activates the buzzer and LED.
Arduino Code:
int rainPin = 2;
int buzzer = 3;
int led = 4;
void setup() {
pinMode(rainPin, INPUT);
pinMode(buzzer, OUTPUT);
pinMode(led, OUTPUT);
}
void loop() {
int rainState = digitalRead(rainPin);
if (rainState == LOW) {
digitalWrite(buzzer, HIGH);
digitalWrite(led, HIGH);
} else {
digitalWrite(buzzer, LOW);
digitalWrite(led, LOW);
}
}
Connection Diagram (Text Representation):
Rain Sensor VCC -> 5V (Arduino)
Rain Sensor GND -> GND (Arduino)
Rain Sensor DO -> Pin 2
Buzzer + -> Pin 3
Buzzer - -> GND
LED + -> Pin 4 (via resistor)
LED - -> GND
Final Output:
When rain is detected, the buzzer sounds and LED glows. When no rain is detected, both remain
off.