Arduino Rain Sensor Interfacing

Rain Sensor Module

Rain Sensor module allows to measure moisture via analog output pins and it provides a digital output when a threshold of moisture is exceeded. The module is based on the LM393 op amp. It includes the electronics module and a printed circuit board that “collects” the rain drops.  As rain drops are collected on the circuit board, they create paths of parallel resistance that are measured via the op amp. The lower the resistance (or the more water), the lower the voltage output. Conversely, the less water,  greater the output voltage on the analog pin.  A completely dry board for example will cause the module to output five volts.

Rain Sensor Module

Rain Sensor Module
Rain Sensor Module

Rain Sensor Module Connections with Arduino

Rain Sensor Module Arduino Connections
Rain Sensor Module Arduino Connections

Arduino Code for Rain Sensor Module

//Rain Sensor Detection of Rain

int nRainDigitalIn = 2;
int nRainVal;
boolean bIsRaining = false;
String strRaining;

void setup() {
void loop() {
  nRainVal = analogRead(A1);
  bIsRaining = !(digitalRead(nRainDigitalIn)); //Cheks Digital Pin 2, Output D0
  if(bIsRaining){   //Cheks Digital Pin 2, Output D0
    strRaining = "YES";
    strRaining = "NO";
  Serial.print("Raining: ");
  Serial.print(" Moisture Level: ");


Open serial monitor to see the result, this project is useful for automated wiper control using rain detection.

Rain Sensor Result
Rain Sensor Result

Similar to rain sensor module there is another sensor called soil moisture sensor. It is used to determine moisture or water contents in soil.

Leave a Reply