Introduction
In this article, we discuss the rain sensor in the market is easily available in analogue and digital format.is Sensing the water level and informing us of digital or analog signals through. now we interfacing the rain sensor with Arduino, ESP8266 And ESP32 Microcontroller.
For the rain sensor in one wire connection, we used the Arduino controller and just connected to any digital pin and we see the reading in the serial monitor is not water present in the sensor displayed, not rain and if water was present in the top of the sensor is displayed rain detected.
Working Principle of Rain Sensor
The working principle of a rain sensor, specifically a capacitive rain sensor, involves detecting changes in conductivity or capacitance caused by the presence of rain or moisture. Here’s a simplified explanation of its working principle
- When raindrops fall on the sensor’s surface, they change the dielectric constant of the material between the plates. Water is a conductive material, so its presence increases the conductivity between the plates.
Specifications of the Rain Sensor
- Sensing Method: Capacitive, optical, or conductive.
- Sensitivity: Sensor in detecting small amounts of rainfall.
- Response Time: in milliseconds (ms).
- Operating Voltage: 5v required.
- Operating Temperature Range: -10 to 55
- Output Signal: Digital And analog format.
Advantages of the Rain Sensor
-
- Water Conservation: Rain sensors are commonly used in irrigation systems to conserve water. They prevent unnecessary watering when sufficient rainfall has already occurred. This helps in reducing water wastage and promoting sustainable water management practices.
- Automated Operation: Rain sensors automate processes that are affected by weather conditions. For example, in automotive applications, rain sensors can automatically activate windshield wipers when rain is detected. This improves convenience and safety by ensuring clear visibility without the need for manual intervention.
- Energy Efficiency: In buildings and smart homes, rain sensors can be integrated with automated systems such as window shutters or awnings. When rain is detected, the sensors can trigger the closing of windows or retracting of awnings, helping to conserve energy by preventing rainwater from entering the building or damaging interior spaces.
- Weather Monitoring: Rain sensors are used in weather monitoring stations to measure and record rainfall data. This information is valuable for meteorological studies, flood prediction, and water resource management.
Disadvantage of the Rain Sensor
-
- False Positives: Is Some time displays the false detecting rainfall.
- False Negatives: Similarly, rain sensors can also provide false negatives, failing to detect rainfall when it is actually occurring. This can happen if the sensor is not properly calibrated or if the rain intensity is below the sensor’s detection threshold. False negatives can result in missed opportunities for water conservation or appropriate action.
- Sensitivity to Environmental Factors: Rain sensors can be affected by environmental conditions such as temperature, humidity, and debris.
- Limited Accuracy and Range: Rain sensors may have limitations in accurately measuring rainfall intensity or providing precise measurements. The accuracy of rain measurement can vary between different sensor models and may not match the precision of dedicated weather monitoring equipment.
Application of the Rain Sensor
- Irrigation Systems: Rain sensors are extensively used in irrigation systems to optimize water usage. They automatically detect rainfall and prevent unnecessary watering, conserving water resources and promoting efficient irrigation practices.
- Automotive Industry: Rain sensors are employed in vehicles to control automatic windshield wipers. The sensors detect rain and adjust the speed and frequency of the wiper blades accordingly, ensuring clear visibility for the driver.
- Building Automation: Rain sensors are integrated into building automation systems to automate the operation of windows, skylights, and awnings. When rain is detected, the sensors can trigger the closing of windows or retracting of awnings to protect the interior spaces from water damage.
- Weather Stations: Rain sensors are an essential component of weather monitoring stations. They provide accurate measurements of rainfall, enabling meteorological studies, flood prediction, and water resource management.
- Greenhouse Control Systems: Rain sensors are used in greenhouse environments to monitor rainfall and adjust the irrigation systems accordingly. This ensures optimal moisture levels for plant growth and prevents overwatering during rainy periods.
Example with Arduino
Circuit Diagram with arduino
Code with 16×2 LCD Display
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
#include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 10, 9, 8, 7); #define sensor_pin A0 int adc_value; int percent_value; void setup() { pinMode(sensor_pin, INPUT); lcd.begin(16, 2); lcd.clear(); lcd.setCursor(0, 0); lcd.print(" Welcome To "); lcd.setCursor(0, 1); lcd.print(" Rain Detector "); delay(2000); lcd.clear(); } void loop() { adc_value = analogRead(sensor_pin); percent_value = map(adc_value, 0, 1023, 100, 0); if (digitalRead) { delay(100); } lcd.setCursor(0, 0); lcd.print("Rain Level: "); lcd.print(percent_value); lcd.print("% "); lcd.setCursor(0, 1); if (percent_value > 30) { lcd.print("Rain Alert....."); delay(300); } else { lcd.print(".....Normal....."); } delay(100); } |
Circuit Diagram with Arduino and GSM
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
//Prateek //wwww.justdoelctronics //https://www.youtube.com/c/JustDoElectronics/videos #include <SoftwareSerial.h> #define RAIN_SENSOR A0 int rain_value = 0; int rain_default = 10; boolean rain_flag = 0; const String PHONE = "+9188305848xx"; #define rxPin 2 #define txPin 3 SoftwareSerial sim800L(rxPin, txPin); void setup() { Serial.begin(115200); sim800L.begin(9600); pinMode(RAIN_SENSOR, INPUT); Serial.println("Initializing..."); sim800L.println("AT"); delay(1000); sim800L.println("AT+CMGF=1"); delay(1000); } void loop() { while (sim800L.available()) { Serial.println(sim800L.readString()); } rain_value = analogRead(RAIN_SENSOR); rain_value = map(rain_value, 0, 1023, 225, 0); if (rain_value >= rain_default) { if (rain_flag == 0) { Serial.println("Rain is Detected."); rain_flag == 1; send_sms(); make_call(); } } else { if (rain_flag == 1) { Serial.println("Rain is not Detected."); } rain_flag = 0; } } void make_call() { Serial.println("calling...."); sim800L.println("ATD" + PHONE + ";"); delay(20000); sim800L.println("ATH"); delay(1000); } void send_sms() { Serial.println("sending sms...."); delay(50); sim800L.print("AT+CMGF=1\r"); delay(1000); sim800L.print("AT+CMGS=\"" + PHONE + "\"\r"); delay(1000); sim800L.print(" Rain Alarm Plz Check"); delay(100); sim800L.write(0x1A); delay(5000); } |
Video
Conclusion
Rain sensors play a vital role in various industries and systems by detecting and responding to rainfall. These sensors offer advantages such as water conservation, automated operation, energy efficiency, and weather monitoring.
Sensor