Skip to content

Rain Sensor Complete Guide

Detect rainfall and automate your world


๐Ÿ“– Overview

The rain sensor detects water on its surface and measures rainfall intensity. Perfect for automatic window closing, irrigation control, and weather stations.

Feature Specification
Output type Analog (0-4095) + Digital (LOW/HIGH)
Intensity range 0% (dry) to 100% (heavy rain)
Response time <1 second
Operating voltage 5V (recommended) or 3.3V
Board compatibility ESP32, ESP8266, Pico W

๐Ÿ”Œ Wiring Guide

ESP32

Sensor Pin ESP32 Pin
VCC 5V
AO GPIO34 (ADC)
GND GND

ESP8266

Sensor Pin ESP8266 Pin
VCC 5V
AO A0
GND GND

Pico W

Sensor Pin Pico W Pin
VCC 5V (pin 40)
AO GP26 (pin 31)
GND GND (pin 38)

Note: Use 5V for best accuracy. 3.3V works but reduces sensitivity.


โš™๏ธ Dashboard Configuration

  1. Go to Device Configuration
  2. Enable Rain Sensor
  3. Set threshold: 2000-3000 (ESP32/Pico) or 500-800 (ESP8266)
  4. Save and regenerate firmware
  5. Flash to your device

๐Ÿ“Š How It Works

Condition ADC Raw Intensity % Digital Output
Dry (no rain) 4095 0% HIGH
Light drizzle 3000 27% HIGH
Light rain 2000 51% LOW
Heavy rain 500 88% LOW
Flood 0 100% LOW

Formula: Intensity% = map(ADC_RAW, 4095, 0, 0, 100)


๐Ÿค– Automation Examples

Example 1: Automatic Window Closer

Setting Value
Sensor Rain
Condition Above
Threshold 80%
Action Turn ON
Target Relay Relay 4 (Window)
Return value 50%
Cooldown 1 minute

Behavior: Rain >80% for 60s โ†’ Window closes | Rain <50% โ†’ Window opens

Example 2: Pause Irrigation

Setting Value
Sensor Rain
Condition Above
Threshold 30%
Action Turn OFF
Target Relay Relay 3 (Pump)
Return value 10%

Example 3: Heavy Rain Alert

Setting Value
Sensor Rain
Condition Above
Threshold 90%
Action Turn ON
Target Relay Relay 5 (Buzzer)
Deactivation Timer
Timer duration 30 seconds

๐Ÿ›ก๏ธ 60-Second Debounce Protection

All rain rules include automatic 60-second debounce: 1. Rain detected โ†’ Debounce STARTED 2. 60 seconds consistent โ†’ Debounce COMPLETE 3. Relay activates

Why? Prevents false triggers from single raindrops, splashing water, or sensor noise.


๐Ÿ”ง Calibration Guide

Board Dry Raw Wet Raw Recommended Threshold
ESP32 4095 500 2500
ESP8266 1023 150 600
Pico W 4095 500 2500

๐Ÿงช Testing Your Sensor

  1. Pour water slowly on sensor
  2. Watch dashboard values change from 0% to 100%
  3. Serial Monitor shows: Rain: 0% โ†’ 45% โ†’ 88%

โš ๏ธ Troubleshooting

Problem Solution
Always 0% Use 5V power, not 3.3V
Always 100% Dry sensor, check for short circuit
No response Check ADC pin: GPIO34 (ESP32), A0 (ESP8266), GP26 (Pico)
False triggers Increase threshold to 3000

๐Ÿงผ Maintenance

Frequency Action
After rain Wipe dry
Monthly Clean with alcohol
Yearly Replace if corroded

Pro tip: Mount sensor at slight angle so water runs off.


โ“ FAQ

Q: Why 60-second debounce?
A: Prevents false triggers from single raindrops. Real rain lasts longer.

Q: Can I use digital output only?
A: Yes, but analog gives intensity percentage for better automation.

Q: How to test without rain?
A: Pour water slowly or use wet cloth.


๐Ÿ”— Next Steps

โœ… Your rain sensor is ready for weather automation!