Rain Sensor with Arduino Uno Program Code

Rain Sensor Working and its Applications

The rain sensor module is an easy tool for rain detection. It can be used as a switch when raindrop falls through the raining board and also for measuring rainfall intensity.

The module features, a rain board and the control board that is separate for more convenience, power indicator LED and an adjustable sensitivity though a potentiometer.

Rain Sensor Working and its Applications

The analog output is used in detection of drops in the amount of rainfall. Connected to 5V power supply, the LED will turn on when induction board has no rain drop, and DO output is high.

When dropping a little amount water, DO output is low, the switch indicator will turn on. Brush off the water droplets, and when restored to the initial state, outputs high level.

Rain Sensor Working and its Applications

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

The FC-37 rain sensor (or other versions like YL-83) is set up by two pieces: the electronic board (at the left) and the collector board (at the right) that collects the water drops.

ALL SENSOR DETAILS:

1. HC-05 – Bluetooth
2. Mpu 6050 accelerometer-gyroscope- -module
3. Flame-sensor
4. Rotary-encoder
5. Force-sensor-fsr400
6. Current-sensor-acs712
7. Flex-sensor
8. IR-sensor-tcrt5000
9. Pulse-sensor-pin
10. Color-sensor-tcs230
11. SD-card-module
12. Oled-with-arduino
13. Addressable-rgb-led-strip-ws1812
14. Relay-module
15. TFT-1-8-display-st7735r
16. 8×8-dot-matrix-display-max7219
17. Smoke-sensor-mq-2
18. Ultrasonic-sensor-HC-sr04
19. PIR-motion-sensor-hc-sr501
20. Tilt-sensor-sw-520d
21. Microphone-sound-sensor
22. Reed-switch-reed-sensor
23. Rfid-reader-Em18
24. Rfid-tag
25. RTC-real-time-clock-ds1307
26. Temperature-sensor-ds18b20
27. Moisture-sensor
28. Rain-sensor
29. Pressure-sensor
30. Accelerometer
31. MOC-3021-circuit
32. DHT11-DHT22-temperature-and-humidity-sensor

SPECIFICAIONS:

1. Adopts high quality of RF-04 double sided material.
2. Area: 5cm x 4cm nickel plate on side.
3. Anti-oxidation, anti-conductivity, with long use time.
4. Comparator output signal clean waveform is good, driving ability, over 15mA.

5. Potentiometer adjust the sensitivity.
6. Working voltage 5V.
7. Output format: Digital switching output (0 and 1) and analog voltage output AO.
8. With bolt holes for easy installation.
9. Small board PCB size: 3.2cm x 1.4cm.
10. Uses a wide voltage LM393 comparator.

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.

WORKING DETAILS:

In simple terms, the resistance of the collector board varies accordingly to the amount of water on its surface.
When the MODULE is in:

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

PIN DETAILS OF RAIN SENSOR:

SENSOR PINARDUINO CONNECTION
A0Any Analog Pin of Arduino
D0Digital Pins
GNDGround of Arduino Board
VCC5V (Regulated Type)

Rains Sensor Test Code:

This is a simple example to show you how you can use the rain sensor in your projects with Arduino. You will read the analog sensor values and print them in the Arduino IDE serial monitor.

 

Copy and paste below given code and test with Arduino IDE.

/*
* Arduino Rain Sensor.
*/
int rainSensePin= 0; // analog pin 0 – sensor i/p
int alertPin= 8; // digital pin 8 – alert o/p
int curCounter= 0; // current counter – goes up by 1 every second while sensing
void setup()
{
Serial.begin(9600);
pinMode(alertPin, OUTPUT);
pinMode(rainSensePin, INPUT);
}
void loop()
{
int rainSenseReading = analogRead(rainSensePin);
Serial.println(rainSenseReading); // use this for serial monitoring if available
delay(250); // relax
// check to see how long it is raining at the threshold level,
// rain strength value from 0 – 1023,
// full rain -to- no rain.
if (curCounter >= 30){ // end of the time delay
digitalWrite(alertPin, HIGH); //raise an alert after x time
}
// If raining is continuing for x amount of time,
// raise an alert .
// When raining is no longer detected, reset the counter.
if (rainSenseReading <300)
{ // while raining at threshold level – see text curCounter++; // increment sensing counter } else if (rainSenseReading >300) { // if not raining at threshold level
digitalWrite(alertPin, LOW); // don’t raise an alert
curCounter = 0; // reset the counter to 0
}
delay(1000);
}

After uploaded Open the Arduino IDE serial monitor to see the results. Then, add drops of water to the collector board and see how that changes the readings.

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

Subramanian
Subramanian

Subramanian MK, currently serving as a workshop instructor at Sakthi Polytechnic College, Erode Tamil Nadu. With a career spanning 25 + years, Subramanian MK has dedicated himself to advancing knowledge in Electronics and Communication Engineering (ECE). His passion for exploring new technologies has led to the development of numerous projects, showcasing expertise in IoT and PCB design.

Articles: 514

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

×

Hi, How can I help you?

×