Arduino Rain Sensor Module Guide and Tutorial

Basic Description

Arduino Rain Detector ModuleThis module allows you 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, the greater the output voltage on the analog pin.  A completely dry board for example will cause the module to output five volts.

Where to Buy a Rain Sensor Module



Bang Good


Rain Sensor Module Pin Outs

Please refer to the drawing below and the following table for the location and description of various pins, controls and indicators.

Arduino Rain Sensor Module Pin Outs

Pin, Control, or IndicatorDescription
VCC+5 Volts Power Source
GNDGround or negative power source
DODigital Output. Goes low when moisture exceeds set threshold.
A0Analog Output - Zero to five volts. The lower the voltage, the greater the moisture.
Power LEDIndicates that power is applied
Output LEDIlluminates when moisture has exceeded threshold set by sensitivity adjustment.
Sensitivity AdjustmentClockwise is more sensitive. Counterclockwise is less sensitive.

Arduino Rain Sensor Module Tutorial

Connecting the Module to the Arduino

Connecting the module up is pretty straight forward.  See the picture below.

Rain Sensor Module Arduino Hookup

Rain Sensor Module Arduino Sketch

The sketch below does a couple of things:

  1.  It monitors the digital output from the module and makes the decision that it is raining if the digital output goes low.
  2. It measures the analog output and provides a moisture level, where 1023 is high and where 0 is very wet.

Copy and paste the sketch below and upload it into your Arduino.

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

void setup() {
void loop() {
  nRainVal = analogRead(nRainIn);
  bIsRaining = !(digitalRead(nRainDigitalIn));
    strRaining = "YES";
    strRaining = "NO";
  Serial.print("Raining?: ");
  Serial.print("\t Moisture Level: ");


Running the Sketch

The sketch will begin immediately uploading.   Open your serial monitor and view the results.   Put a little water ( a sponge works good) onto the sensor and see the moisture level decrease.

If you get the board wet enough, the serial monitor should indicate that it’s raining.   If not, try turning the sensitivity adjustment clockwise.


  1. November 3, 2015
  2. Hadiza Tafida November 3, 2015

Leave a Reply

Your email address will not be published. Required fields are marked *