Rain Sensor
The Rain Sensor is mainly used to detect rainfall and its intensity. It is commonly applied in automotive adaptive lighting (AFS) systems, automatic windshield wiper systems, and smart window systems.
The rain sensor is essentially a board coated with nickel in a linear pattern. Its basic working principle is to detect rainfall by measuring the conductivity of water droplets. It utilizes changes in conductivity between two electrodes to measure the presence of water. These two electrodes have an air gap between them, which normally acts as an open circuit. When water droplets come into contact with the electrodes, their conductivity allows current to pass through the droplets, forming a closed circuit. This, in turn, changes the resistance value between the electrodes, altering the voltage drop across them.
Module Source
Purchase Link:
https://detail.tmall.com/item.htm?abbucket=0&id=41266204564&ns=1&spm=a21n57.1.0.0.4c52523cd1r9Zc
Baidu Netdisk Download Link:
https://pan.baidu.com/s/10bjbsmcOh2N7YGDS3PquPw
Password: psfm
Specifications
Operating Voltage: 3.3V - 5V
Detection Range: 1 meter
Output Types:
DO (Digital Output) AO (Analog Output)
Readout Method: ADC (Analog-to-Digital Conversion) and digital output (0 or 1)
Pin Count: 4 pins (2.54mm pitch header)
Hardware Connection
- Connect the VCC pin on the raindrop sensor’s control module to the 5V output on the development board.
- Connect the GND pin on the raindrop sensor’s control module to the GND on the development board.
- Connect the analog output (usually labeled as AO) on the raindrop sensor’s control module to the A0 analog input pin on the development board.
- The digital output (usually labeled as DO) on the raindrop sensor’s control module is not used in this example.If needed, you can configure a digital pin, such as pin 2, and set it to input mode.
Note: The connection between the raindrop detection plate and the module is not polarized—connect either way, and it will function correctly.
Usage Method
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 9, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
// 定义连接到传感器模拟输出的Arduino的模拟输入引脚
const int rainSensorPin = A0;
void setup() {
// 开始串行通信
Serial.begin(9600);
}
void loop() {
// 读取模拟引脚上的电压值 (0-1023)
int sensorValue = analogRead(rainSensorPin);
// 将读数映射到相应的模拟电压值(0V-5V)
float voltage = sensorValue * (5.0 / 1023.0);
// 打印结果到串行监视器
Serial.print("Sensor Value: ");
Serial.print(sensorValue);
Serial.print(", Voltage: ");
Serial.println(voltage);
// 等待一段时间后再次读取
delay(1000);
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Usage Testing
When water is detected, the voltage decreases.