01
Introduction
The raindrop sensor, also known as the rainwater sensor, is used to detect whether it is raining and the amount of rainfall. It consists of a large rainwater detection board and a control board. When raindrops fall on the detection board, the control board converts this into a digital signal (D) and an analog signal (A) output.
The raindrop sensor can be used in automatic windshield wiper systems for cars, sunroof systems, and more.
02
Principle
The raindrop detection board is coated with nickel in a linear fashion, utilizing the change in conductivity between two electrodes to measure the presence of water droplets. There is an air gap between these two electrodes, which is normally in an open circuit state. When a water droplet contacts the electrodes, the conductivity of the droplet allows current to flow through it, forming a current loop and thereby changing the resistance value between the electrodes, which alters the voltage drop across them.
The control board includes an LM393 operational amplifier. When raindrops accumulate on the circuit board, they form a parallel resistance path that can be measured by the operational amplifier.
The control board has two indicator lights: a power indicator (PWR-LED) and an output signal indicator (DO-LED). The power indicator remains lit when powered on, and the output signal indicator does not light up when there is no rain; when raindrops are present, the output signal indicator lights up.
The raindrop board and control board are separate, making it convenient to extend the wires. The large area of the raindrop board is more conducive to detecting rainwater.
The control board has two outputs: a digital output (DO) and an analog output (AO). When connected to a 5V power supply, the power light is on. When there are no water droplets on the sensing board, the DO output is high; when a droplet of water is present, the DO output goes low. If the water droplet is wiped away, it returns to a high output state. The sensitivity can be adjusted using a blue variable resistor.
Turning the knob clockwise increases sensitivity, while turning it counterclockwise decreases sensitivity.
The AO analog output connects to the analog input of a microcontroller. By comparing the analog value converted to a digital value, the amount of rainfall can be detected. The larger the rainfall, the smaller the resistance value, resulting in a larger digital value. Different values correspond to the amount of rainfall in millimeters, which requires physical measurement, as the placement of the raindrop board can affect the results.
03
Wiring
Connect the detection board and control board with a PH2.0 wire, and then use a 4-wire to DuPont wire to connect to the expansion board:
- G: Power negative, connect to GND, black wire
- V: Power positive, connect to 3.3V, red wire
- D: Digital signal line, connect to P0, green wire
- A: Analog signal line, connect to P1, blue wire
04
Program
The digital output port uses the P0 pin to receive and stores it in the variable sun.
If the sun value is 0, display a rain icon, indicating that it is raining.
If the sun value is 1, display a sun icon, indicating that it is not raining.