A rain sensor module detects the presence of water droplets on its surface, giving Arduino a simple signal to trigger actions — close a window, retract an awning, pause outdoor irrigation, or log rainfall events. The module costs about ₹30-50 and uses a pair of interleaved conductive traces on a PCB; when raindrops bridge these traces, resistance drops and the comparator circuit triggers. This guide covers wiring, code, and practical rain-activated automation projects for Indian conditions.
How Rain Sensor Modules Work
The rain sensor kit has two parts: a sensing pad (PCB with interleaved traces) and a controller board with an LM393 comparator. In dry conditions, resistance between the traces is very high (megaohms). When water droplets bridge the traces, resistance drops to a few kilohms. The controller board provides both an analogue output (proportional to wetness) and a digital output (above/below threshold set by the onboard potentiometer).
Specifications
- Operating voltage: 3.3V-5V
- Outputs: Analogue (A0) and Digital (D0)
- Detection area: ~40×55 mm typical
- Response time: <1 second
Wiring and Arduino Code
| Module Pin | Arduino Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| A0 | A0 (analogue reading) |
| D0 | D2 (digital threshold) |
const int analogPin = A0;
const int digitalPin = 2;
const int buzzerPin = 8;
void setup() {
Serial.begin(9600);
pinMode(digitalPin, INPUT);
pinMode(buzzerPin, OUTPUT);
Serial.println("Rain Sensor Ready");
}
void loop() {
int analogValue = analogRead(analogPin);
int digitalValue = digitalRead(digitalPin);
Serial.print("Wetness: ");
Serial.print(analogValue);
Serial.print(" | Rain: ");
if (digitalValue == LOW) {
Serial.println("YES - Rain detected!");
tone(buzzerPin, 1500, 200);
} else {
Serial.println("No rain");
}
delay(500);
}
The analogue reading gives you a rough indication of how wet the sensor is. Dry = ~1023, light drizzle = ~600-800, heavy rain = ~200-400, fully wet = ~100-200. The digital output flips to LOW when wetness exceeds the potentiometer threshold.
Adjusting Sensitivity
Turn the potentiometer on the controller board to adjust the digital trigger threshold. Clockwise increases sensitivity (triggers on smaller droplets), counterclockwise decreases it. For Indian monsoon conditions where you want to detect the first few drops before heavy rain starts, set high sensitivity. For dew/condensation rejection, reduce sensitivity so only actual rain triggers the output.
Rain-Activated Projects
1. Automatic Window Closer
Detect rain and activate a linear actuator or motor to close a window. Particularly useful in India where sudden monsoon downpours can soak furniture and electronics near windows. Use a relay module to control a 12V linear actuator.
2. Smart Clothesline Retractor
Indian households commonly dry clothes on outdoor clotheslines or terraces. A rain sensor triggers a motor that pulls the clothesline under a covered area when rain starts. Combine with a DHT22 to also retract when humidity exceeds 90% (indicating imminent rain).
3. Irrigation System Rain Override
If you have an automatic irrigation system, the rain sensor provides a critical override — don’t water the garden when it’s already raining. Wire the rain sensor’s digital output as an input to your irrigation controller to skip watering cycles during rain.
4. Weather Station Rain Logging
Log rain events with timestamps to an SD card or cloud service. Track rainfall patterns over weeks and months. While the basic rain sensor can’t measure rainfall volume (it’s a yes/no detector), it accurately logs rain duration and frequency.
Improving Outdoor Durability
The standard rain sensor PCB corrodes quickly outdoors because DC current flowing through wet traces causes electrolysis. Solutions:
- Power the sensor intermittently: Use a digital pin to power the sensor only during readings (every 5 seconds). This dramatically reduces corrosion.
- Apply conformal coating: Spray a thin layer of silicone conformal coating on the traces. It slows corrosion while still allowing water detection.
- Mount at an angle (30-45°): Rain collects; excess water drains off. This prevents permanent puddles on the sensor surface that accelerate corrosion.
- Replace regularly: At ₹30-50 each, budgeting a replacement every 3-6 months for outdoor use is reasonable.
// Power saving: only power sensor during readings
const int sensorPower = 7; // Digital pin to power sensor
void setup() {
pinMode(sensorPower, OUTPUT);
digitalWrite(sensorPower, LOW); // Off by default
}
int readRainSensor() {
digitalWrite(sensorPower, HIGH);
delay(100); // Allow voltage to stabilise
int value = analogRead(A0);
digitalWrite(sensorPower, LOW); // Turn off immediately
return value;
}
Frequently Asked Questions
Can the rain sensor measure rainfall amount?
No. It detects the presence of rain (binary yes/no) and rough wetness level (analogue). For rainfall volume measurement, you need a tipping bucket rain gauge — a mechanical device where each “tip” represents a fixed volume (usually 0.2 mm of rainfall). The tipping action can trigger a digital input on Arduino for counting.
How do I prevent false triggers from dew?
Reduce the sensitivity via the potentiometer so that thin dew films don’t trigger the digital output. Alternatively, use the analogue reading with a higher software threshold. Mount the sensor vertically or at a steep angle so dew drips off rather than accumulating.
Will the sensor work during Indian monsoon heavy rain?
Yes — in fact, heavy rain is the easiest condition to detect. The challenge is the sensor staying saturated (permanently wet) during prolonged rain, making it unable to distinguish between rain and wet-but-not-raining conditions. After rain stops, the sensor needs time to dry before it can detect the next rainfall event. Mount it in a semi-sheltered spot where it dries quickly between showers.
Can I use this sensor to detect water leaks indoors?
Yes. Place the sensing pad on the floor near washing machines, water heaters, or under sinks. When water leaks onto the pad, it triggers an alarm. For leak detection, the corrosion issue is less critical since it’s indoors and rarely activated.
Conclusion
Rain sensor modules are among the cheapest and simplest Arduino sensors, but they enable practical automation that’s genuinely useful in Indian conditions — protecting clothes from sudden showers, saving water by pausing irrigation, and logging weather events. At ₹30-50, even if you replace the sensing pad every few months due to outdoor corrosion, it remains one of the most cost-effective sensors in your toolkit.
Get rain sensors and weather monitoring components at Zbotic’s sensor modules store.
Add comment