Extra 5% OFF Use Code: OL05
Free Shipping over ₹999

ESP32 Rain Drop with Arduino IDE

Introduction

The Raindrop Sensor is used to detect rainfall using a rain-sensing board and a control module.
The sensor provides both analog and digital outputs, which the ESP32 can read to determine rain intensity or presence.
It is commonly used in automatic wiper systems, agricultural irrigation, and home automation for smart weather response.

Required Components

  • ESP32 Board
  • Rain Drop Sensor
  • Jumper wires
  • Breadboard

Pinout

Circuit Diagram / Wiring

  • Rain Sensor VCC → 5V (Arduino)
  • Rain Sensor GND → GND (Arduino)
  • Rain Sensor DO → 14 (Arduino)
  • Rain Sensor AO → 34 (Arduino)

Code / Programming

// Define sensor pins
const int analogPin = 34;  // Use an ADC1-compatible analog pin on ESP32
const int digitalPin = 14; // Digital output pin from the sensor

void setup() {
  Serial.begin(115200);        // Start serial communication at 115200 baud
  pinMode(digitalPin, INPUT);  // Set digital pin as input
  Serial.println("Raindrop Sensor Initialized");
}

void loop() {
  int analogValue = analogRead(analogPin);      // Read analog value
  int digitalValue = digitalRead(digitalPin);   // Read digital output

  Serial.print("Analog Value: ");
  Serial.print(analogValue);
  Serial.print(" | Digital Value: ");
  Serial.println(digitalValue == LOW ? "Rain Detected" : "No Rain");

  delay(1000);  // Delay before next reading
}

Explanation

  • The sensor detects the presence and intensity of rain using a conductive surface that changes resistance when wet.
  • The analog pin on ESP32 measures moisture level, while the digital pin detects rain presence (HIGH = dry, LOW = wet).
  • This setup is ideal for automating actions like alerts, wipers, or irrigation during rainfall.

Troubleshooting

  • If analog values stay constant, clean the rain board and ensure good wire connections.
  • If digital value never changes, try adjusting the onboard potentiometer to set the correct rain threshold.
  • Use GPIO 32–39 only for analog readings to avoid issues with ESP32’s ADC functionality.

    Leave a Reply

    Your email address will not be published.

    Need Help?