Introduction
The objective of this post is to describe a cheap rain sensor that can be used to detect rain with microcontrollers such as the Arduino or the ESP8266.
This is a very cheap and easy to use sensor. Figure 1 shows this sensor, which is composed by a plaque and a circuit board.

The working principle
As told before, the rain sensor used is composed by two parts. The first one is the effective sensor, which is a plaque that is exposed to the rain. This plaque has two strips of conductive material, very close to each other, but without touching.
So, if we apply a voltage between the the two strips, it will be an open circuit. Nevertheless, when we expose this surface to the rain, the water that falls closes the circuit between the strips and a different voltage can be measured.
Keep in mind that when the rain drops the two strips will not be short circuited because water is not a perfect conductor [1][2]. So, this sensor will act as a variable resistor [3], which will be lower when more water falls on the surface, connecting the stripes in more points. I’ve tested the resistance of the sensor with a multimeter after applying some water drops and it was about 65 kΩ.
The second part is the electronic circuit board responsible to process the signal from the plaque and expose it as two signals, one digital and another analog.
So, we have a digital output pin, which operates as active-low, indicating that rain is being detected or not. Since this pin is active-low, it will have a value of GND when rain is detected, and VCC when rain is not detected.
Since, as stated, the rain sensor will act as a variable resistor, it’s output will be an analog voltage that needs to be converted to this digital one. So, the electronic circuit uses a LM393 comparator [4] to compare this analog voltage to a certain threshold and output GND or VCC accordingly.
The PCB of this electronic circuit has a potenciometer that we can change to adjust this threshold, making the sensor more or less sensible to the rain drops.
Additionally, the sensor has an analog output with a variable voltage that depends on the resistance of the sensor and thus, on the amount of water on it.
This module can work with voltage supplies of both 3.3 V and 5 V [5], making it possible to use with both Arduino and the ESP8266.
You can check the schematic of the module here. Just keep in mind that there can be different versions from different manufacturers.
Where to buy
This is a really cheap sensor that can be bought at multiple online electronic stores. But, as usual, I recommend eBay, where it can be bought for less than 1 euro.
Troubleshooting
Although this is a relatively simple sensor to interface with, some problems may arise when using it.
The first one is related to the sensitivity of the module. The configuration of the potenciometer that comes when we buy it may not be the best, so the output of the digital pin of the module is always at GND or VCC, independently if there is water or not on the sensor. So, we may have to play around with the resistor a little bit until we find a nice equilibrium.
Also, some people experience problems with the salinity of the water [3], which may not be conducting well enough. You can change the type of water used or add a little bit of salt to check if it solves the problem. You can also use a resistor between the two strips of the sensor to try to simulate the connectivity caused by the water drops, and check if the module works properly.
If the module doesn’t work at all, it may be a unit with defect. From my personal experience, I once bought one of these modules with a defect that was putting the digital LED with a value of GND no matter if there were raindrops or not. The problem persisted even if I changed the sensitivity of the potenciometer, and so it was really a defective unit.
Related readings
References
[1] http://www.physlink.com/education/askexperts/ae61.cfm
[2] http://www.lenntech.com/applications/ultrapure/conductivity/water-conductivity.htm
[3] http://www.instructables.com/id/Arduino-Modules-Rain-Sensor/?ALLSTEPS
[5] http://blog.circuits4you.com/2016/04/interfacing-rain-sensor-to-arduino.html
Pingback: ESP8266: Detecting rain drops | techtutorialsx
Pingback: ESP8266: Detecting rain drops | techtutorialsx