How Rain Sensor Works with Arduino - Electronic and Telecommunication Engineering

Post Top Ad

Responsive Ads Here

How Rain Sensor Works with Arduino

Share This





    With the climate being as unpredictable as ever, it’s smooth to go away your skylights open, handiest for it to  start raining, leaving the interior beneath at threat. With this rain sensor, however, you could prevent this from occurring.

    You can use this sensor to display rain or slushy snow/hail and ship closure requests to electronic shutters, home windows, awnings or skylights whenever the rain is detected.

How Rain Sensor works?


    The operating of the rain sensor is pretty straightforward.

    The sensing pad with collection of uncovered copper traces, collectively acts as a variable resistor (similar to a potentiometer) whose resistance varies according to the amount of water on its surface.






This resistance is inversely proportional to the quantity of water:


   ðŸ‘‰ The more water on the surface means better conductivity and will result in a lower resistance.

   ðŸ‘‰ The greater water on the surface approach better conductivity and could bring about a lower resistance.

    The sensor produces an output voltage in line with the resistance, which by means of measuring we are able to decide whether or not it’s raining or not.


                                         Hardware Overview

A typical rain sensor has two additives.

The Sensing Pad

    The sensor includes a sensing pad with series of exposed copper traces this is located out within the open, in all likelihood over the roof or wherein it could be tormented by rainfall.

    Usually those lines are not related however are bridged through water.




The Module


   The sensor additionally contains an digital module that connects the sensing pad to the Arduino.

   The module produces an output voltage consistent with the resistance of the sensing pad and is made to be had at an Analog Output (AO) pin.

   The equal signal is fed to a LM393 High Precision Comparator to digitize it and is made to be had at an Digital Output (DO) pin.








   He module has a integrated potentiometer for sensitivity adjustment of the virtual output (DO).

   You can set a threshold with the aid of the use of a potentiometer; So that after the quantity of water exceeds the brink rate, the module will output LOW otherwise HIGH.

💬 the knob clockwise to boom sensitivity and counterclockwise to lower it.





   Apart from this, the module has  LEDs. The Power LED will mild up even as the module is powered. The Status LED will slight up when the virtual output goes LOW.

Rain Sensor Pinout


The rain sensor is amazing smooth to apply and best has 4 pins to attach.









AO (Analog Output) pin gives us an analog sign some of the supply value (5V) to 0V.

DO (Digital Output) pin offers Digital output of inner comparator circuit. You can connect it to any digital pin on an Arduino or right now to a 5V relay or similar tool.

VCC pin materials electricity for the sensor. It is suggested to power the sensor with among three.3V – 5V. Please phrase that the analog output will vary relying on what voltage is supplied for the sensor.

GND is a ground connection.


Rain Sensor with Arduino

First you need to deliver strength to the sensor. For that you may join the VCC pin on the module to 5V at the Arduino.

However, one normally regarded difficulty with these senors is their quick lifespan while uncovered to a wet environment. Having power carried out to the sensing pad continuously, speeds the charge of corrosion notably.

To triumph over this, we recommend which you do no longer strength the sensor constantly, however power it handiest when you're taking the readings.

An smooth way to accomplish this is to connect the VCC pin to a virtual pin of an Arduino and set it to HIGH or LOW as as consistent with your requirement.

Also the total strength drawn by the module (with both LEDs lit) is set 8 mA, so it is k to power the module off a digital pin on an Arduino.

So, permit’s join the VCC pin on the module to the digital pin #7 of an Arduino and GND pin to ground.

Finally, join the DO pin on the module to the virtual pin #8 to your Arduino.






Calibrating Rain Sensor


   The module has a built-in potentiometer for calibrating the digital output (DO).

   By turning the the knob of the potentiometer, you can set a threshold. So that when the amount of water exceeds the brink price, the Status LED will light up and the digital output (DO) will output LOW.

    Now to calibrate the sensor, sprinkle some water at the sensing pad and adjust the pot clockwise so that the Status LED is ON after which alter the pot lower back counterclockwise just until the LED is going OFF.

   That’s it your sensor is now calibrated and prepared for use.


Detecting Rain and  Arduino Code

Now vicinity the rain sensor in a vicinity such that precipitation can fall without delay into the sensor, likely over the roof. Also place it slightly tilted (~20°) to facilitate the float of water.

Note that the electronic module isn't always designed to be water resistant, be careful to install it so that handiest the sensing pad will are available contact with water.


ARDUINO CORDING


   // Sensor pins
#define sensorPower 7
#define sensorPin eight

void setup() 
pinMode(sensorPower, OUTPUT);

// Initially hold the sensor OFF
digitalWrite(sensorPower, LOW);

Serial.Begin(9600);


void loop() 
//get the reading from the function under and print it
int val = readSensor();
Serial.Print("Digital Output: ");
Serial.Println(val);

// Determine reputation of rain
if (val) {
Serial.Println("Status: Clear");
}
else {
Serial.Println("Status: It's raining");
}

delay (1000); // Take a analyzing each 2d
Serial.Println();


//  This function returns the sensor output
int readSensor() 
digitalWrite(sensorPower, HIGH); // Turn the sensor ON
remove(10); // Allow electricity to settle
int val = digitalRead(sensorPin); // Read the sensor output
digitalWrite(sensorPower, LOW); // Turn the sensor OFF
return    val; // Return the rate
}



    Once the cartoon is uploaded, open a Serial Monitor window to peer the output from the Arduino. You should see a digital output HIGH while the weather is apparent. To see it feel water, you could sprinkle some water at the sensing pad.





Code Explanation:


The sketch starts offevolved with the announcement of the Arduino pins to which the sensor’s VCC and DO pins are connected.


#define sensorPower 7
#define sensorPin 8 


Now within the the Setup phase, we first declare the energy connection to the sensor as output, then we set it low so no power flows via the sensor initially. We additionally setup the serial screen.


pinMode(sensorPower, OUTPUT);

digitalWrite(sensorPower, LOW);

Serial.Begin(9600);

In the loop section, we call readSensor() function time and again on the c program languageperiod of 1 2d and print the again price along with the repute.


if (val) {
Serial.Println("Status: Clear");
}
 else {
Serial.Println("Status: It's raining");
}

delay (1000);

Serial.Println();

The readSensor() function is used to get the cutting-edge virtual output of the sensor. It turns the sensor ON, waits for 10 milliseconds, reads the virtual cost from the sensor, turns the sensor OFF after which returns the end result.



No comments:

Post a Comment

Post Bottom Ad

Responsive Ads Here

Pages