

The MH-RD Rain Sensor is a simple yet effective electronic component designed to detect the presence of rain. It consists of a rain detection board and a control module. When rainwater comes into contact with the detection board, the sensor outputs a signal that can be used in various applications. This sensor is commonly used in automated irrigation systems, weather monitoring stations, and smart home projects to prevent unnecessary watering or to trigger alerts during rainfall.








| Pin Name | Description |
|---|---|
| VCC | Power supply input (3.3V to 5V) |
| GND | Ground connection |
| OUT | Output signal (digital or analog, depending on the connection used) |
| Pin Name | Description |
|---|---|
| S | Signal pin connected to the control module |
| + | Power supply input (connected to VCC on the control module) |
| - | Ground connection (connected to GND on the control module) |
S, +, and - pins of the detection board to the corresponding pins on the control module.VCC pin to a 3.3V or 5V power source.GND pin to the ground of your circuit.OUT pin to a digital or analog input pin on your microcontroller.// MH-RD Rain Sensor Example Code for Arduino UNO
// This code reads both the digital and analog outputs of the sensor
// and prints the results to the Serial Monitor.
const int digitalPin = 2; // Digital output pin from the sensor
const int analogPin = A0; // Analog output pin from the sensor
void setup() {
pinMode(digitalPin, INPUT); // Set digital pin as input
Serial.begin(9600); // Initialize serial communication
}
void loop() {
int digitalValue = digitalRead(digitalPin); // Read digital output
int analogValue = analogRead(analogPin); // Read analog output
// Print the sensor readings to the Serial Monitor
Serial.print("Digital Output: ");
Serial.print(digitalValue); // 0 = Rain detected, 1 = No rain
Serial.print(" | Analog Output: ");
Serial.println(analogValue); // Varies based on water level
delay(1000); // Wait for 1 second before the next reading
}
No Output Signal:
Erratic Readings:
Corrosion on the Detection Board:
Sensor Not Detecting Rain:
Q: Can the sensor detect the intensity of rainfall?
A: Yes, the analog output provides a variable signal that corresponds to the amount of water on the detection board, which can be used to estimate rainfall intensity.
Q: Is the sensor suitable for outdoor use?
A: The detection board is designed for outdoor use, but it is recommended to protect it from prolonged exposure to water to prevent corrosion.
Q: Can I use the sensor with a 3.3V microcontroller?
A: Yes, the sensor operates at both 3.3V and 5V, making it compatible with most microcontrollers.
Q: How do I clean the detection board?
A: Use a soft cloth and isopropyl alcohol to gently clean the board. Avoid using abrasive materials.