Skip to content

How do You Make a Rain Alarm Project?


A rain alarm is a useful device that alerts when it starts raining. This allows proactively taking actions like closing windows to prevent rainwater from entering a building. This article provides a step-by-step guide on making a simple rain alarm project using basic electronic components.

The working principle and key stages like circuit design, PCB making, code development, enclosure design and testing will be covered. Additionally, tips to enhance the functionality and aesthetics of the project are provided. A FAQ section addresses common queries regarding rain alarm projects.

Principle of Operation

The rain alarm works on the following principle:

  • A sensor module detects rainfall and outputs a signal.
  • This signal is processed by a microcontroller.
  • When rain is detected, the microcontroller activates an alarm driver circuit.
  • The alarm driver triggers a buzzer to generate an audible alert.
  • An LED is also blinked to give visual indication.
  • If no rain is detected after some time, the alarm is switched off automatically.

Circuit Diagram

The circuit diagram of the rain alarm project is shown below:

It consists of the following key components:

  • Rain sensor module – Detects rain and outputs logic level signal.
  • Arduino Nano – Microcontroller board to process sensor data.
  • Buzzer and LED – Audiovisual indication when rain is detected.
  • Transistor – Works as alarm driver to switch buzzer ON/OFF.
  • Resistors – Current limiting resistors for LED and transistor base.


  • The rain sensor module has an exposed PCB that senses rainfall through a change in electrical conductance between its tracks.
  • When rain is detected, the sensor outputs a logic HIGH signal.
  • The Arduino Nano microcontroller reads this signal on one of its input pins.
  • When a HIGH state is detected, the Arduino turns ON the buzzer and LED by sending a HIGH signal from its output pin to the transistor.
  • The transistor conducts and allows current to flow through the buzzer and LED to activate them.
  • If no rain is detected for some time, the Arduino turns off the alarm automatically.

Circuit Design Details

  • The rain sensor module requires 5V supply and provides a 3.3V logic level output when rain is detected.
  • The Arduino Nano operating at 5V can directly interface with this 3.3V signal without need for logic level conversion.
  • A general purpose NPN transistor BC547 acts as driver to switch the buzzer ON/OFF by Arduino control signal.
  • The buzzer requires 12V supply and draws over 200mA current when activated.
  • A 1K resistor at transistor base limits the current through Arduino output pin.
  • A 470Ω resistor limits current through the LED for visual indication.

Prototype on Breadboard

Before designing a custom PCB, building a prototype on a breadboard allows testing the circuit and making modifications easily.

  • Use jumper wires to connect the components as per the circuit diagram.
  • Double check all connections to avoid shorts or open circuits.
  • Connect the Arduino Nano to your computer and upload the Arduino code given further below.
  • Power up the circuit by connecting the 12V adaptor and 5V from Arduino USB port.
  • Test rain detection by spraying some water droplets. The buzzer and LED should turn ON.
  • Make sure the alarm turns OFF automatically after some time.

PCB Design

A custom PCB makes the project more compact, robust and professional. Some tips for PCB design:

  • Use CAD software like EasyEDA or KiCAD for board layout.
  • Ensure adequate copper trace widths to handle buzzer current.
  • Include power supply filtering capacitors.
  • Use thick traces or polygons for power connections.
  • Design mounting holes for standoffs to secure board inside enclosure.
  • Make provisions for extending sensor wires to place module outside.
  • Add indicator LEDs to show power status.
  • Check footprint compatibility of components.

Coding the Logic

The Arduino program to implement the rain sensing logic with automatic alarm shut off:


Copy code

//Define sensor pin #define sensorPin 2 //Define alarm driver pin #define alarmPin 6 //Sensor state int sensorState = 0; void setup() { //Configure sensor pin as input pinMode(sensorPin, INPUT); //Configure alarm pin as output pinMode(alarmPin, OUTPUT); } void loop() { //Read rain sensor state sensorState = digitalRead(sensorPin); //If rain detected if(sensorState == HIGH) { //Activate alarm digitalWrite(alarmPin, HIGH); //else if no rain } else { //Turn off alarm digitalWrite(alarmPin, LOW); } //Small delay before checking again delay(100); }

The logic checks the sensor continuously and triggers the alarm only on detecting rain. Else it remains off.

Enclosure Design

A protective enclosure makes the alarm standalone and deployable outdoors:

  • 3D print or laser cut an enclosure box to required dimensions.
  • Make cutouts for buzzer, LEDs, switches etc.
  • Use cable glands for wire connections.
  • Install PCB on standoffs and wire up components.
  • Seal any gaps for waterproofing using silicone gel.
  • Add an extendable mounting arm for positioning sensor outside.
  • Use aesthetically pleasing sounds/indicators.

Testing and Debugging

Rigorously test the rain alarm before final deployment:

  • Check circuits by applying test inputs.
  • Load test alarm by connecting additional buzzer load.
  • Check range by spraying water from different distances.
  • Ensure false triggers are not happening when no rain.
  • Verify automatic shut off is happening after 1-2 minutes.
  • Keep the enclosure outdoors under slight drizzle and heavy downpour to validate performance.
  • Improve water sealing, sound volume or sensitivity if issues are found.

Applications of the Rain Alarm

The rain alarm project has many real-life applications:

  • Install on windows to alert before they get wet in the rain.
  • Use in greenhouses, sheds to indicate leakage.
  • Attach to roof gutters to check for overflow.
  • Use at outdoor events to watch for rain.
  • Alert fishermen so they can take shelter from impending rain.
  • Provide advance warning of rain to farmers.

Future Enhancements

Some ways to improve and add features to the basic rain alarm:

  • Use WiFi to send mobile alerts when activated.
  • Add a wireless receiver horn for remote indication.
  • Incorporate a raindrop flow rate sensor to quantify rainfall.
  • Log data using IoT cloud platforms for weather monitoring.
  • Include automatic window closing mechanism.
  • Solar power the device for remote outdoor operation.


In this article, a step-by-step guide to building a DIY rain alarm project using basic electronic components and modules was provided. The working principle, circuit design, Arduino code, PCB fabrication and enclosure design aspects were elaborated. Tips for testing, troubleshooting and enhancing the functionality were also discussed. The rain alarm presented makes an interesting hobby electronics project as well as serving practical real-life weather monitoring needs. The instructions and details provided will be useful for students, hobbyists and makers to build their own customizable rain alarm systems.


Q1. Does the rain sensor require any power supply?

Most basic rain sensor modules are completely passive and do not require any external power. The detection signal output is generated in response to rain droplets.

Q2. Can piezoelectric sensors be used for rain detection?

Yes, piezo discs/elements can output a signal in response to impinging rain drops. But they require support circuitry to process their high impedance charge output.

Q3. How to increase the range of detection?

Use thicker/longer connecting wires between the rain sensor and alarm circuit to increase the detection distance. A wireless radio link can also remotely place the detector.

Q4. Is Arduino the best microcontroller choice?

Arduino provides a simple way to read sensors and control outputs. But low cost microcontrollers like ARM Cortex M0 can also be used with appropriate programming.

Q5. What are typical use cases for the rain alarm?

Typical uses are to alert before windows, skylights get wet due to rain, prevent flooding of sheds, greenhouses, activate coverings for vehicles, warn farmers about rain, etc.

    GET A FREE QUOTE PCB Manufacturing & Assembly Service
    File Upload