How to use the Rain Sensor with Arduino
How to use the Rain Sensor with Arduino
INTRODUCTION
Rain Sensor measures moisture via analog output pins, and it provides a digital output when a threshold of moisture is exceeded. It includes the electronics module and a printed circuit board that “collects” the raindrops. The lower the resistance (or the more water), the lower the voltage output.
APPLICATIONS
It detects the presence of water and can be used to detect rain with the digital input. The rain sensor can also be used to evaluate the intensity of rain with the analog input.
WIRING DIAGRAM
GND – GND
VCC – 5V
A0 – Analog Pin A1
D0 – Digital Pin 2
CODE
int drain = 2; int arain = A0; int val; int val2; void setup(){ Serial.begin(9600); pinMode(2, INPUT); } void loop() { val = digitalRead(drain); Serial.println(val); val2 = analogRead(arain); Serial.println(val2); }
END RESULT
Open the serial terminal. Put some water drops on the surface of the water sensor and witness the changing values in the serial terminal.
ADDITIONAL RESOURCES