Rain Alarm Circuit Using a Rain Sensor and Buzzer (With and Without Arduino)
Build a rain alarm with a rain sensor module and buzzer, first with a BC557 transistor and then with Arduino. Wiring tables, code and fixes.
On this page
Clothes drying on the roof, grain spread in the yard, a window left open: in the monsoon, a small alarm that beeps when the first drops fall is truly useful. In this tutorial you will build the same rain alarm in two ways. The first uses only a rain sensor module, one transistor and a buzzer. The second adds an Arduino so you can also read how wet it is and print it on your computer.
Both versions use the very common rain sensor module (often sold as YL-83 or FC-37 style): a sensing plate with copper tracks, plus a small control board with an LM393 comparator chip. It is easy to find in Nepali electronics shops and online sellers.
Safety note
Everything here runs on 5 V DC. Water and electricity do not mix, so keep the control board, the battery and all breadboard parts dry and under cover. Only the sensing plate goes outside. Never connect the sensing plate to mains voltage or any supply above 12 V.
What you need
Scroll sideways to see all columns.
| Item | Qty | Version | Notes |
|---|---|---|---|
| Rain sensor module (plate + LM393 control board) | 1 | Both | Control board has pins VCC, GND, DO, AO |
| Active piezo buzzer, 5 V | 1 | Both | Rated for 15 mA or less |
| PNP transistor BC557 (or BC558) | 1 | No Arduino | TO-92 package |
| Resistor 2.2 kΩ | 1 | No Arduino | Base resistor |
| Resistor 10 kΩ | 1 | No Arduino | Base-to-emitter pull-up |
| Arduino Uno (or clone with CH340) + USB cable | 1 | Arduino | CH340 clones need the CH340 driver on your PC |
| Jumper wires, breadboard | 1 set | Both | |
| 5 V supply (USB charger or power bank) | 1 | Both | Arduino version uses the USB cable |
| Digital multimeter | 1 | Both |
How the module works
The sensing plate is a board with interleaved bare copper tracks. Dry, the tracks are not connected, so its resistance is very high. Water drops bridge the tracks and let a little current flow, so the resistance falls.
The control board has two outputs:
- AO (analog out): a voltage that goes down as the plate gets wetter.
- DO (digital out): the LM393 compares the plate voltage with a level you set using the blue potentiometer. On most of these modules DO is HIGH when dry and goes LOW when wet, and a small LED on the board lights when it is wet. Some boards differ, so test yours with a multimeter before building.
Version A: without Arduino
Why a PNP transistor?
DO goes LOW when it rains, but a buzzer needs to switch on at that moment. A PNP transistor does exactly this: it turns on when its base is pulled LOW compared with its emitter. So when DO drops to 0 V, the BC557 switches on and sends 5 V to the buzzer.
For the BC557, hold it with the flat side facing you, legs down. Left to right they are Collector, Base, Emitter (C-B-E), the same order as the BC547.
Connection table
Scroll sideways to see all columns.
| From | To |
|---|---|
| Sensing plate | Two-wire lead to the control board |
| Control board VCC | +5 V |
| Control board GND | Supply GND |
| Control board DO | 2.2 kΩ resistor, other end to BC557 base |
| BC557 base | 10 kΩ resistor to +5 V (emitter) |
| BC557 emitter | +5 V |
| BC557 collector | Buzzer + (long leg) |
| Buzzer − | Supply GND |
Signal path in one line:
Rain on plate → LM393 DO goes LOW → 2.2 kΩ → BC557 base → emitter-collector on → buzzer sounds
Base resistor check
Use an active piezo buzzer rated for 15 mA or less at 5 V in both builds. The comparator sinks about (5 − 0.7 − 0.4) / 2200 ≈ 1.8 mA through the base resistor, plus the module’s own pull-up current. The base receives about 1.7 mA after allowing for the 10 kΩ pull-up.
Build steps
- Place the BC557 on the breadboard, flat face toward you.
- Wire the emitter to +5 V, the base to DO through 2.2 kΩ, and the collector to the buzzer +. Add the 10 kΩ resistor from base to emitter.
- Connect the buzzer − to GND and the module VCC and GND to the supply.
- Power on. The buzzer should stay silent when the plate is dry.
- Drop a little water on the plate. The module LED lights and the buzzer sounds.
- Turn the blue potentiometer so the alarm starts at the wetness you want (one or two drops is a good start).
Version B: with Arduino
Here the Arduino reads DO to sound the buzzer and also reads AO to show a relative wetness reading.
Wiring table
Scroll sideways to see all columns.
| Arduino Uno pin | Connects to |
|---|---|
| 5V | Rain module VCC |
| GND | Rain module GND, buzzer − |
| D2 | Rain module DO |
| A0 | Rain module AO |
| D8 | Buzzer + (active buzzer) |
| D13 | Onboard LED (no wiring needed) |
Code
// ElectroDai - Rain alarm with Arduino Uno
// Rain module: DO -> D2, AO -> A0. Active buzzer on D8.
const int DO_PIN = 2; // digital output of the rain module
const int AO_PIN = A0; // analog output of the rain module
const int BUZZER_PIN = 8; // active buzzer
const int LED_PIN = 13; // onboard LED
// Most modules give LOW on DO when wet. Change to HIGH if yours is opposite.
const int WET_LEVEL = LOW;
unsigned long lastPrint = 0; // time of the last serial print
void setup() {
pinMode(DO_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
bool raining = (digitalRead(DO_PIN) == WET_LEVEL);
digitalWrite(BUZZER_PIN, raining ? HIGH : LOW);
digitalWrite(LED_PIN, raining ? HIGH : LOW);
// Print the analog value twice per second (typically lower when wet)
if (millis() - lastPrint >= 500) {
lastPrint = millis();
Serial.print("AO = ");
Serial.print(analogRead(AO_PIN));
Serial.print(" Rain: ");
Serial.println(raining ? "YES" : "no");
}
}
Open Serial Monitor at 9600 baud. A dry plate should read near 1000, and a wet plate falls to a few hundred or less.
Testing with a multimeter
- Supply (power on): 5 V between module VCC and GND.
- DO voltage dry: close to 5 V. Wet: close to 0 V. If yours is reversed, the logic is opposite and Version A will not work without changes.
- AO voltage: dry, about 4.5-5 V; wet, it falls toward 1 V or lower.
- Buzzer voltage (Version A): across the buzzer when sounding, about 4.8 V. If it is below 3 V the transistor is not turning on fully.
- Plate check (power off): Ω range between the two plate leads. Dry, it shows OL (open). A drop of water shows a high value that falls to tens of kilohms.
Troubleshooting
Scroll sideways to see all columns.
| Symptom | Likely cause | Fix |
|---|---|---|
| Buzzer sounds all the time | Sensitivity pot too high, or plate dirty or damp | Turn the pot to reduce sensitivity; dry and clean the plate |
| Never sounds | DO polarity different from mine | Measure DO when wet; set WET_LEVEL for the Arduino sketch, or use a module with active-LOW DO for Version A |
| Buzzer buzzes weakly | Passive buzzer used, or transistor reversed | Use an active buzzer; check C-B-E |
| Module LED lights, buzzer silent | Base resistor missing or buzzer backwards | Check the 2.2 kΩ and the buzzer polarity |
| Serial Monitor shows garbage | Wrong baud rate | Set 9600 in Serial Monitor |
| Plate tracks turn green or black | Corrosion from current flowing through water | Switch the module off when not needed, rinse and dry it |
| Arduino not detected | CH340 driver missing on a clone | Install the CH340 driver and select the right port |
FAQ
Can I use a passive buzzer?
With Arduino, yes: replace the digitalWrite with tone(BUZZER_PIN, 2000) and use noTone(BUZZER_PIN) to stop it. In Version A a passive buzzer will only click, because DC has no tone.
Does the plate last outdoors?
Not forever. The bare copper corrodes. For a long-lasting build, power the module only when needed, or protect the back and the edges with clear nail polish and keep the connector under cover.
How do I make it sound only once?
Add a bool alarmDone flag in the Arduino code so the buzzer turns on for a few seconds, then stops until the plate dries.