Working Principle
Rain sensors detect the presence and intensity of water on their sensing surface. Two main types are common:
Resistive rain sensor: A PCB with exposed interleaved copper traces. When dry, resistance is very high (open circuit). Water droplets bridge the traces, creating conductive paths that lower resistance proportionally to the wetted area. A comparator/amplifier module converts this to analog and digital outputs.
Capacitive rain sensor: Uses two conductor plates separated by a dielectric. Water on the surface changes the dielectric constant, altering the capacitance. Capacitive types are more durable (no exposed metal to corrode) but more expensive.
Electrical Characteristics
| Parameter | Resistive Module (FC-37/YL-83) |
|---|---|
| Supply Voltage | 3.3–5 V |
| Digital Output | HIGH (dry) / LOW (rain detected) |
| Analog Output | ~1023 (dry) to ~0 (fully wet) on 10-bit ADC |
| Threshold Adjust | On-board potentiometer (sets digital trip point) |
| Sensing Area | ~50 × 40 mm PCB |
| Response Time | Near instantaneous (water contact) |
| Comparator | LM393 dual comparator IC |
| Current Draw | ~15 mA active |
Interfacing with an MCU
The module has 4 pins: VCC, GND, DO (digital output), and AO (analog output). Connect AO to an ADC pin for rain intensity measurement, or use DO for simple rain/no-rain detection. Adjust the potentiometer to set the sensitivity threshold for the digital output.
Calibration
- Dry baseline: Record the analog value when the sensor is completely dry (should be near 1023/4095)
- Wet threshold: Apply water drops and set the potentiometer so DO triggers at your desired rain level
- Intensity mapping: Create a rainfall intensity scale from analog values: >900 = dry, 600–900 = light rain, 300–600 = moderate, <300 = heavy rain
- Heating: In cold climates, add a resistive heater pad beneath the sensor to prevent ice/frost triggering
Code Example
/*
* Rain Sensor (FC-37/YL-83) — Arduino
* Wiring: VCC → D7 (power control), GND, AO → A0, DO → D8
*/
#define RAIN_POWER 7 /* Control power to reduce corrosion */
#define RAIN_AO A0
#define RAIN_DO 8
void setup() {
Serial.begin(9600);
pinMode(RAIN_POWER, OUTPUT);
pinMode(RAIN_DO, INPUT);
Serial.println("Rain Sensor Ready");
}
int readRain() {
digitalWrite(RAIN_POWER, HIGH);
delay(10); /* Allow sensor stabilisation */
int val = analogRead(RAIN_AO);
digitalWrite(RAIN_POWER, LOW);
return val;
}
void loop() {
int raw = readRain();
bool rain = !digitalRead(RAIN_DO); /* DO LOW = rain */
Serial.print("Analog: ");
Serial.print(raw);
Serial.print(" Rain: ");
if (raw > 900) Serial.println("DRY");
else if (raw > 600) Serial.println("LIGHT RAIN");
else if (raw > 300) Serial.println("MODERATE RAIN");
else Serial.println("HEAVY RAIN");
delay(30000); /* Check every 30 seconds */
}
Real-World Applications
Automatic Irrigation, Weather Stations & Car Wipers
Rain sensors are used in automatic irrigation systems (skip watering when raining), weather stations, car windshield wiper automation, retractable awning/roof controllers, leak detection systems, and smart skylight actuators. Automotive rain sensors use infrared reflection (not resistive) for reliability, but the basic principle serves well in outdoor IoT projects.
Limitations
- Corrosion: Resistive sensors corrode rapidly if continuously powered; limited outdoor lifespan (weeks to months).
- False positives: Fog, dew, spider webs, and insects can trigger false rain detection.
- No rainfall rate: Cannot measure actual mm/hour precipitation; only wet/dry intensity.
- Orientation sensitive: Must be mounted horizontally and exposed to open sky; enclosed installations don’t work.