Introduction: Arduino Modules - Rain Sensor

Picture of Arduino Modules - Rain Sensor

Quick and simple start guide for using and exploring the Rain Sensor module sometimes called a "Raindrops Sensor Module" with an Arduino.

I figured since I recently wrote up an Instructable about flame sensors, a type of water sensor might just be a good equalizer.

Materials needed:

Step 1: Getting to Know Your Rain Sensor:

Picture of Getting to Know Your Rain Sensor:

Usage:
Rain sensors are used in the detection of water beyond what a humidity sensor can detect.

How it works:

The rain sensor detects water that completes the circuits on its sensor boards' printed leads. The sensor board acts as a variable resistor that will change from 100k ohms when wet to 2M ohms when dry. In short, the wetter the board the more current that will be conducted.

Pins:

A0.......... Analog output

D0......... Digital output

GND..... Ground

VCC...... Positive voltage (input: 5v for analog 3.3v for Digital.)

Loop Pins:

+ .......... Sensor board hookup A

- .......... Sensor board hookup B

Dimensions:

2.17 in x 1.57 in x 0.31 in (5.5 cm x 4.0 cm x 0.8 cm)

Weight:

0.28 oz (8 g)

Step 2: Testing and Troubleshooting:

Picture of Testing and Troubleshooting:

Testing:

To test the Rain Sensor and ensure that it is working correctly connect the VCC to a 5v power source and GND. Try placing a few droplets of water on the Rain sensor detection board and the D0-LED should light up.

Troubleshooting:

If the D0-LED does not light up check the following:

  • Is the module hooked up properly?
  • Sometimes salinity is an issue with these units, this one worked fine with filtered, bottled water, but in some instances you may have to add a bit of salt to increase the waters conduction.
  • This might be a bit more tricky, but for some reason two different models by two different manufacturers have had defects in their soldering skills. Make sure all of the little SMD's and connectors have been soldered on properly. IE - are solder joints actually soldered?
  • If none of the previous makes the D0-LED light up, your sensor may be defective.

Step 3: Wiring to an Arduino:

Picture of Wiring to an Arduino:

To wire the Rain Sensor to the Arduino for analog, simply connect the following as shown:

Rain Sensor ................. Arduino

VCC............................... 5v

GND.............................. GND

A0.................................. Analog in 0

Rain Sensor ................ Sensor Board

+.................................... +

-..................................... -

Step 4: Arduino Sketch Example:

Picture of Arduino Sketch Example:

The following code maps and reads the analog values given by the Rain Sensor (0-1024). The Rain Sensor will have the following reaction with this code:

  • If the Sensor Board is completely soaked; "case 0" will be activated and " Flood " will be sent to the serial monitor.
  • If the Sensor Board has water droplets on it; "case 1" will be activated and " Rain Warning " will be sent to the serial monitor.
  • If the Sensor Board is dry; "case 2" will be activated and " Not Raining " will be sent to the serial monitor.

* The output in "case 2", "Not Raining" is just for this demonstration. When I used this code in production I omitted the output for this case and just had the alert for "Rain Warning" and "Flood".

* To view the output, point a serial monitor such as Putty at your Arduino.

* This code is constantly updating in order to provide a real time feedback of the Rain Sensor.

Code:

Attached due to formatting.

Comments

NaweedR (author)2016-06-01

How can I get sensor to not be so sensitive? Approximately 1 droplet of water will equal a flood and a few sprinkles equal a rain warning.

KingIsulgard (author)NaweedR2016-10-06

Obviously this sensor can only be either "wet" or "dry" with nothing in between. To make it less "sensitive" on would have to work with an array of these sensors and make them cover a greater area. Then you could write your own algorythm to define how hard it's raining based on how many sensors got activated of the array.

CraigT60 (author)KingIsulgard2017-06-18

That would only be true if rain and the traces were perfect conductors, but they aren't. This kind of sensor will show a difference between a few drops and several. It doesn't have to get completely covered to reach minimum resistance, but it can tell the difference between two drops, five drops, and twenty.

That said, this isn't a rain gauge, and it's main job is to show whether or not there is surface moisture. It can detect trace amounts that a rain gauge won't. It can also detect dew and frost, and, more importantly, it can show how quickly surface moisture evaporates. This is important to know when, for example, one is scheduling automatic watering, since wet leaves aren't good for most plants.

Can you tell me what algorythm should I use if i need to measure the rain in mm/hr just using this sensor.

To measure an amount of rain collected in a container you would want to use a Float sensor insead of this rain sensor.

This type of sensor can not measure that kind of unit.

You could put a grid of 4 by 4 of these sensors and say that when half of them get wet, it's actually "raining" (feel free to play with the amount of sensors and the percentage of them to get activated), to avoid having a single drop be equal to a flood. But that's about it. Once a drop falls on them, they keep activated so you can't measure anything of drop size.

ADIKARUNAH (author)2017-04-10

Hi Sir,

How long maximum distance between Rain sensor and sensor board ? How long maximum distance between sensor board and Arduino board ?

H

pink banana (author)2017-02-28

aawsome invention

sadeem88 (author)2016-12-29

how can i order it please? and how much is it?

roadrunr74 (author)2016-09-27

great easy test of the sensor! thank you!

gulliverrr (author)2016-08-05

not sure if it is intentional but the delay(1) at the end is actually causing to check for rain 1 thousand times every second which I find overkill. Changing it to delay(1000) for once per second seemed more suitable for my needs but I believe most cases would be covered sufficiently with once per minute, that is delay(60000). Great 'ible btw!

AtholereA (author)2016-03-01

can i use a rain sensor to monitor river level? If yes, how?

kontaktbl (author)AtholereA2016-07-27

Hi

you suppose to use ultrasonic distance sensor

Reichenstein7 (author)AtholereA2016-03-09

Not a single one, it will activate if any part of the sensor board gets wet. Maybe if you had multiple boards, but I am thinking there are better ways of doing this, like a float system that turns a potentiometer. A potentiometer would be much more relaible and percise.

Shiva kumarR1 (author)2016-05-02

where can i get code

priscus (author)2016-04-09

Nice project,

where can i get the Proteus library for this sensor please

dancopy (author)2016-03-31

Hello Friend! First, thanks for the tutorial!
How would the code to drive a stepper motor or servo motor? Thank you

igloo63 (author)2016-03-25

Hi

Great job and thank you for sharing this tutorial. It was a real pleasure playing with my arduino and rain sensor. However, I could like to use this rain sensor on Rapberry Pi. Any idea to wire and python code ?

zamirul (author)2015-10-19

Can i know the coding for this project?

Reichenstein7 (author)zamirul2015-10-22

The code is in the .PDF file above.

EdgarEstrada (author)2015-10-10

Hello! I don´t know if this has happened to you.

I installed this project to my Arduino and it works great, however every 2-3 days it gets "stuck", I mean, if (for example) there is rain at night, in the next morning it says is still raining (even if the sensor is not wet at all)... I have to go up to where it is installed, clean it with a dry cloth,and then the measures are normal again.

Do you know why this happens?

Maybe some residue in the Dew that is falling on the sensor at night?

I thought about that, but the farm is located outside any city, and anything I leave outside in the rain gets totally cleaned, no traces of dirt of any kind..

Altoidian (author)2015-09-18

This worked great. I tested it with several liquids and found it measured accurately across the board, for everything from distilled water to coffee and soda pop. The sensitivity adjustment is ideal for proerly adjusting for any type of liquid. I even tested water with baking soda and full strength venegar. I could adjust it so that it read pretty much the same for all the liquids I tested. Distilled water had the lest conductivity and I doubed the guage would work at all, but it conducted just enough to get an acceptable output. After all, rain water is pretty much distilled water with a little dust in it.

bask185 (author)2015-08-16

Is there also some documentation about this sensor, so I can transform the analog reading in a more saying variable, for instance liter/meter^2?

I cant find anything

Reichenstein7 (author)bask1852015-08-28

This sensor is really more of just an on or off variable sent back to your controller when it gets smattered by water.

babymii (author)2015-08-11

can i buy this?

Reichenstein7 (author)babymii2015-08-11

Sure, there are a ton of these sensors on Ebay.

ibenkos (author)2014-10-18

Smart idea! I really like this project. Thanks for shearig :)

Reichenstein7 (author)ibenkos2015-04-30

Thank you =)

seamster (author)2014-09-03

Nice project!

About This Instructable

116,886views

129favorites

License:

Add instructable to: