Rain Drop Sensor Module with Arduino

I came across the rain drop sensor module and was interested in its application area. Like I wondered if this rain drop sensor can be use to harness power like using solar. But I came to know that this cannot be achieved. The reason being simply that it is just a rain detector or conductivity detector and requires external power supply to power it. However I wanted to know its electronics circuit and connection to arduino. Below is how to connect the rain drop sensor module with Arduino. A LED is also used in the circuit as an visual indicator that it is raining. 

arduino with rain drop sensor module

The D0 or the digital pin of the rain sensor module is connected to pin 2 of Arduino and the LED indicator is connected to pin 8 of Arduino. The Vcc and GND pins of the rain sensor module connected to the +5V and GND of Arduino.

The code that I used is below. The program reads the digital output of the rain sensor and when rain drop is detected the LED is turned on. Also the status is displayed in serial monitor.


const int rainDigitalPin = 2;  // Digital pin connected to DO of sensor
const int ledPin = 8;         // Built-in LED or external LED pin

void setup() {
  pinMode(rainDigitalPin, INPUT);
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
  Serial.println("Rain Sensor Initialized...");
}

void loop() {
  int digitalValue = digitalRead(rainDigitalPin); // LOW when rain is detected
  
  // Show rain status based on digital signal
  if (digitalValue == LOW) {
    Serial.println(" | Rain Detected!");
    digitalWrite(ledPin, HIGH); // Turn on LED
  } else {
    Serial.println(" | No Rain.");
    digitalWrite(ledPin, LOW); // Turn off LED
  }

  delay(100); // 1 second delay
}

So rain sensor is easy to use with Arduino.


Post a Comment

Previous Post Next Post