Rain Detector Using Arduino

Rain Sensor

Image result for rain sensor

The rain sensor is used to detect water and it can detect beyond of what a humidity sensor do.

The rain sensor has a built-in potentiometer for sensitivity adjustment of the digital output (D0). It also has a power LED that lights up when the sensor is turned on and a digital output LED.

Image result for rain sensor

How does it work?

Basically, the resistance of the collector board varies accordingly to the amount of water on its surface.

When the board is:

  • Wet: the resistance increases, and the output voltage decreases
  • Dry: the resistance is lower, and the output voltage is higher

 Components Required

  • Rain Sensor: FC-37 or YL-83
  • Arduino UNO
  • Breadboard
  • 220 Ohm Resistors
  • Red LED
  • Green LED
  • Jumper wires




/*  Rain sensor Tutorial
 *  www.genbays.com 

int rainPin = A0;
int greenLED = 6;
int redLED = 7;
// you can adjust the threshold value
int thresholdValue = 500;

void setup(){
  pinMode(rainPin, INPUT);
  pinMode(greenLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  digitalWrite(greenLED, LOW);
  digitalWrite(redLED, LOW);

void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(rainPin);
  if(sensorValue < thresholdValue){
    Serial.println(" - It's wet");
    digitalWrite(greenLED, LOW);
    digitalWrite(redLED, HIGH);
  else {
    Serial.println(" - It's dry");
    digitalWrite(greenLED, HIGH);
    digitalWrite(redLED, LOW);

Upload the following sketch to your Arduino board

After Uploading the code start adding drops of water to the collector board.

When the value goes below a certain threshold, a red LED will turn on, and when the value goes above a certain threshold, a green LED will turn on.