Rain Detection Sensor

Rain Detection Sensor

Introduction

This experiment shows how to use a rain detection sensor with an Arduino to detect rainfall.

Rain Detection Sensor

Components Needed

Circuit Setup

  1. Connect the rain sensor's output pin to a digital input pin on the Arduino (e.g., D2).
  2. Connect the LED to a digital output pin using a 220-ohm resistor in series.

The LED will light up when the rain sensor detects water droplets.

Rain Detection Circuit Setup

Code for Rain Detection Sensor

Upload the following code to your Arduino to detect rain:


const int rainPin = 2;
const int ledPin = 13;

void setup() {
  pinMode(rainPin, INPUT);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  if (digitalRead(rainPin) == HIGH) {
    digitalWrite(ledPin, HIGH);  // LED on when rain is detected
  } else {
    digitalWrite(ledPin, LOW);   // LED off when no rain
  }
}
            

Explanation

The rain sensor detects water droplets on its surface and sends a HIGH signal to the Arduino when it detects rain. This triggers the LED to light up.

Troubleshooting