This project for Rain Detector Circuit using Arduino shows how to detect rain, here, rain sensor plate feels water drops.
Then, the module gives analog and digital signals, and the Arduino reads these signals and finally, the LED glows when it starts raining. Therefore, this low-cost project is easy for beginners to build.
Arduino Code:
int rainAnalog = A0; // analog signal from sensor
int rainDigital = 7; // digital rain signal
int redLed = 13; // red LED for rain alert
int greenLed = 9; // green LED for no rain
int buzzer = 8; // buzzer pin
void setup() {
pinMode(rainDigital, INPUT);
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
}
void loop() {
int analogValue = analogRead(rainAnalog);
int rain = digitalRead(rainDigital);
Serial.print("Analog Value: ");
Serial.println(analogValue);
if (rain == 0) {
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
digitalWrite(buzzer, HIGH);
}
else {
digitalWrite(redLed, LOW);
digitalWrite(greenLed, HIGH);
digitalWrite(buzzer, LOW);
}
delay(300);
}
Code Explanation:
- A0 reads rain level.
- D7 gives wet or dry signal.
- Rain detected then red LED and buzzer is ON, green LED is OFF.
- No rain then green LED is ON, red LED and buzzer is OFF.
- Serial monitor shows analog value.
- Serial monitor shows water strength by analog value.
- Higher analog means more water.
Circuit Working:

Parts List:
| Components | Quantity |
|---|---|
| Resistor 220Ω 1/4 watt | 2 |
| Arduino UNO | 1 |
| Rain Drop Detection Sensor Module | 1 |
| LED Red and Green | 1 each |
| Buzzer 5V | 1 |
| USB Cable | 1 |
To begin with, rain plate has two metal lines; water makes conduction between lines and resistance decreases when water present.
After that, sensor module converts resistance change to voltage and then Arduino reads voltage from analog pin and also Arduino reads digital output from DO pin.
Now, the buzzer sounds when it detects rain; if it detects rain, the red LED1 turns ON to indicate the presence of rain and if it does not detect rain, the green LED2 turns ON to indicate that there is no rain.
Formulas with Calculations:
Sensor acts like a variable resistor, with water, resistance goes low and AO voltage goes high.
Circuit uses voltage divider formula:
Vout = Vin * (R2 / (R1 + R2))
here,
- Vout is voltage across R2.
- Vin input voltage.
- R1 fixed resistor inside the sensor module.
- R2 is sensor resistance inside the module.
Example assume:
- Dry sensor is about 100k ohm.
- Wet sensor is about 20k ohm.
- Vin is 5V.
Dry sensor example:
R2 = 100k ohm
Vout = 5 * (100k / (50k + 100k))
Vout = 5 * (100k / 150k)
Vout = 5 * 0.666
Vout = 3.33V
Wet sensor example:
R2 = 20k ohm
Vout = 5 * (20k / (50k + 20k))
Vout = 5 * (20k / 70k)
Vout = 5 * 0.285
Vout = 1.42V
Arduino reads these voltages as numbers from 0 to 1023.
How to Build:
To build a Rain Detector Circuit using Arduino following are the steps one should follow:
- First, take all the parts as shown in circuit diagram.
- Next, connect rain sensor plate to module: + to +, – to -, S to SIG.
- Then module VCC pin connect to Arduino 5V, module GND pin connect to Arduino GND, module AO pin goes to Arduino A0 and module DO pin goes to Arduino D7.
- Now LED1 red positive leg go to Arduino D13 through 220 ohm resistor and LED1 negative leg go to GND.
- Also, LED2 green positive leg through 220 ohm resistor to Arduino D and And LED2 green negative leg go to GND
- After that, buzzer positive pin go to Arduino D8 and buzzer negative pin go to GND
- Breadboard used to hold LED and resistor.
Conclusion:
To conclude, this is simple and easy Rain Detector Circuit using Arduino; rain sensor plate gives water level and then Arduino shows rain condition with LED.
In addition, useful project for automatic windows, weather station, farms and home systems and is also easy to build and with low cost.
Leave a Reply