Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Arduino
110 min
Share

How to use Raindrop Sensor with Arduino

By connecting a Raindrop Sensor to an Arduino board, a basic Rain Detection System can be constructed with ease. This type of system is applicable to a wide range of industries.

Project Video

Overview

In this tutorial, we will build a basic rain sensor using Arduino with a buzzer. You can then use this set-up to build anything you wish on top of it.

Getting the Items

Arduino Uno R3 (Voltaat Version)
Get Item
Raindrops Detection Sensor
Get Item
Passive Buzzer – 5V
Get Item
Jumper Wires - Male to Male (40 Pack)
Get Item

Steps

Wiring it Up

Connect the wires between the Raindrop Sensor and the Arduino and the passive buzzer as shown in the image below.


Connections from the rain drop sensor to arduino :



• VCC  → Arduino 5V pin


• GND →  Arduino GND pin


• A0 →  Arduino pin A0



Connections from the Arduino to the passive buzzer:



• Arduino GND pin → buzzer GND pin (- pin)


• Arduino pin 3 → buzzer VCC pin (+ pin)

Coding


/*
Voltaat learn (http://learn.voltaat.com)
Link for full tutorial: put the link of the tutorial here

Tutorial: How to use Raindrop Sensor with Arduino!

The function of this code is to switches on the buzzer when rain falls on the raindrop sensor, and display on your computer that rain has been detected.


Connections from the rain drop sensor to arduino :

• VCC  → Arduino 5V pin

• GND →  Arduino GND pin

• A0 →  Arduino pin A0

Connections from the Arduino to the passive buzzer:

• Arduino GND pin → buzzer GND pin (- pin)

• Arduino pin 3 → buzzer VCC pin (+ pin)

*/


#define rainfall A0

#define buzzer 3

int value;

int set=10;

void setup() {

 Serial.begin(9600);

 pinMode(buzzer,OUTPUT);

 digitalWrite(buzzer,LOW);
 
 pinMode(rainfall,INPUT);

 }


void loop() {

value = analogRead(rainfall);

Serial.println(value);

value = map(value,0,1023,225,0);

Serial.println(value);

if(value>=set){

 Serial.println("rain detected🌧");

 digitalWrite(buzzer,HIGH);

}

else{

 digitalWrite(buzzer,LOW);

}

delay(200);

}


   

Testing it Out

know when your plant needs watering

Once you’ve connected the Raindrop Sensor to the Arduino and uploaded the code, open the serial monitor by clicking on its icon.

know when your plant needs watering

The serial monitor will display whether rain has been detected or not.

know when your plant needs watering

Resources

No items found.