Introduction
Water detector / Rain detector / Water Drip detector all have the same concept and would be the same project. Well you just got to change the name. If you are thinking of electronics that you want to setup in a liquid environment then learning this is a must. Lets go ahead and start learning.
In the world of electronics, learning to set up sensors in liquid environments is an essential skill. One project that exemplifies this is the rain detector. Whether you’re a gardening enthusiast or a weather enthusiast, this DIY rain sensor project will not only enhance your understanding of sensor technology but also provide a practical solution for various applications. In this comprehensive guide, we’ll walk you through building your own rain detector using the YL-83 sensor and the LM393 comparator, explaining its working principles, components needed, providing circuit and pin diagrams, and sharing the Arduino code to make it all come to life.
If you want to setup a rain detector because drying up clothes is a task and continuously keeping a track of the rain is difficult. You can build a project that programs your cloth dryer stand to be pulled in, Yeah its a lot mechanical!. Lets learn about the basic sensor to detect water or any liquid that conducts electricity. This sensor can be used as both Analog and Digital.
Working Principle
The Sensor when detects a water with the series of copper traces in the sensing pad. This resistance varies with the amount of water on it. More the water on it the lesser the resistance and better the flow of current. (As we know with water the conductivity is better)
The sensor that outputs voltage levels that help us determine if its raining or not / there is a drip or leakage or not.
The rain detector operates on a straightforward principle: it detects the presence of water or moisture by measuring electrical conductivity. Raindrops act as conductive bridges, completing a circuit when they touch the sensor’s surface. The LM393 comparator is used to convert the analog signal from the YL-83 sensor into a digital signal. When rain is detected, the comparator sends a signal to the Arduino, allowing you to trigger actions or receive alerts based on the detected rain.
How does the sensor work with Arduino
The sensor when detects the water with the help of the copper traces. The output voltage at the terminal changes, this voltage is fed to the Arduino through an Analog Pin (A0 – A5 for Arduino Uno) . The Arduino then maps the values of the voltage change.
If we want to digitize the output we can use a comparator LM393 that will allow us to adjust the sensitivity of the sensing pad and give a digital output to the Arduino that will be fed to the Arduino Digital Pin (D2-D13 for Arduino Uno)
Components required
- Water Sensor (Sensor Pad and LM393 Comparator)
- Arduino Uno
- LED x 1
- 220Ω Resistor x 1
Pin Diagram Sensor
Circuit Diagram
We are going to give power supply to the Rain sensor only while we take readings, as continuously running a current through the copper traces will lead to corrosion of the tracks and the durability of our sensor will decrease.
Code
// Sensor pins
/*using D7 as a power pin
as we will power the detector module only when we take the readings
(This is done in order to avoid corrosion) for more read at electronicssimplified.in
*/
#define SensorPower 7
#define SensorPin 8
void setup() {
pinMode(SensorPower, OUTPUT);
pinMode(SensorPin, INPUT);
// Keep the sensor turned OFF
digitalWrite(SensorPower, LOW);
Serial.begin(9600);
}
void loop() {
//get the reading from the function below and print it
int SensorVal = readRainSensor();
Serial.print("Digital Output: ");
Serial.println(SensorVal);
// Determine status of rain
if (SensorVal) {
Serial.println("Clear and No Rain");
} else {
Serial.println("Its Raining / Its Dripping");
}
delay(10000); // Take a reading every 10 seconds
Serial.println("-----------------------------------");
}
// This function returns the sensor output
int readRainSensor() {
digitalWrite(SensorPower, HIGH); // Turn the sensor ON
delay(10); // Allow power to settle
int SensorVal = digitalRead(SensorPin); // Read the sensor output
digitalWrite(SensorPower, LOW); // Turn the sensor OFF
return SensorVal; // Return the value
}
Conclusion
This Sensor can be used for many operations and for conducting liquids. Please note that we cannot use liquids that enhance or cause damage to our copper tracks as there are many fluids that will speeded the corrosion process.
Building your rain detector with the YL-83 sensor and LM393 comparator is not only an engaging DIY project but also a valuable addition to your electronics skills. You’ve learned about the fundamental working principles, gathered the necessary components, connected them as per the circuit diagram, and programmed the Arduino to take action when rain is detected. This versatile rain sensor can be incorporated into various applications, from weather monitoring systems to smart garden irrigation. Embrace the possibilities, and let your DIY rain detector enhance your understanding of electronics and weather sensing. Happy tinkering!