Arduino - Rain Sensor - Buzzer
In this tutorial, We will explore the process of utilizing Arduino for rain detection and creating an alarm system with a buzzer.
Hardware Required
Or you can buy the following kits:
| 1 | × | DIYables STEM V3 Starter Kit (Arduino included) | |
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some links direct to products from our own brand, DIYables .
About 12V Buzzer and Rain Sensor
If you do not know about 12V buzzer and rain sensor (pinout, how it works, how to program ...), learn about them in the following tutorials:
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
For a project that lasts, screw terminals hold the wires better than jumper wires. Put a Screw Shield V2 or a Proto Screw Terminal Block Shield on top of the Arduino, then tighten each wire under a screw. The wiring stays the same. Only the wires now go to the screw terminals, as shown below.

This image is created using Fritzing. Click to enlarge image
Arduino Code
Quick Steps
- Connect Arduino to PC via USB cable
- Open Arduino IDE, select the right board and port
- Copy the above code and open with Arduino IDE
- Click Upload button on Arduino IDE to upload code to Arduino
- Move your hand in front of sensor
- Listen to 12V buzzer's sound
Code Explanation
Read the line-by-line explanation in comment lines of source code!
Video Tutorial
We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.