A Rain Sensor detects the presence of water droplets. When it rains, the sensor triggers an alarm (buzzer) or an action (close a window, retract an awning).
The rain sensor module has a conductive PCB with interleaved traces. When water bridges these traces, the resistance drops significantly. The comparator module reads this change and outputs a digital LOW or an analog value.
```cpp int rainPin = A0; int buzzerPin = 8;
void setup() { pinMode(buzzerPin, OUTPUT); Serial.begin(9600); }
void loop() { int sensorValue = analogRead(rainPin); Serial.println(sensorValue);
if (sensorValue < 500) { // Threshold (lower = more water) digitalWrite(buzzerPin, HIGH); // ALARM! } else { digitalWrite(buzzerPin, LOW); } delay(100); } ```
Build this project with the Rain Sensor Alarm System kit!
Explore our collection of DIY kits and components. All project components mentioned in this guide are available in our store.
Browse All Projects