What is a Rain Alert System?
Have you ever left your shoes outside and come back to find them completely soaked? Or forgotten to close your bedroom window before a surprise shower? A rain alert system is a small electronic device that detects the first drop of rain and warns you right away - before anything gets wet!
In this project, you will build your very own rain alert system using an Arduino and a rain sensor. When rain is detected, an LED light turns on and your laptop screen shows the message "RAIN DETECTED". When it stops, the light turns off and shows "NO RAIN". Simple, smart, and really cool to show off!
What Will Your Child Learn From This Project?
- How a sensor detects real-world changes like rain
- How an Arduino reads a sensor and decides what to do
- How to write and upload basic Arduino code
- How to connect wires correctly and safely
- How electronics and coding work together in real life
Parent tip: This is a great project to build together. No prior coding or electronics experience is needed. Just follow each step and have fun experimenting!
Which Components Do You Need for a Rain Alert System Project?
Before you start, gather these five things. All of them come inside your CYFI kit.
1. Arduino Uno board
This is the brain of the project. It reads what the sensor tells it and then decides to turn the LED on or off.
2. Rain sensor module
This comes in two parts. The stripey black board is the sensing pad that gets wet. The small blue board is the comparator that reads the signal from the pad.
3. LED light (any colour)
This is your visual alarm. It lights up the moment rain is detected. You can use the LED already built into the Arduino board at pin 13, so you do not even need a separate one to start.
4. Jumper wires (3 wires)
These are the short coloured wires that connect the sensor to the Arduino. Use one red, one orange (or yellow), and one blue (or black) to keep it easy to follow.
5. A laptop or computer with a USB cable
This powers the Arduino and lets you see the messages on screen using the Arduino IDE app (free to download).
Fun fact: The Arduino Uno was first made in 2010 in Italy. Today, millions of kids and engineers around the world use it to build everything from robots to weather stations!
How Do You Connect the Rain Sensor to Arduino?
This section shows you how to connect the rain sensor to the Arduino. Follow the wire connections listed below carefully. Use the circuit image shown below as a reference.
Wire Connections (3 wires from sensor to Arduino):
|
From (Rain Sensor)
|
To (Arduino)
|
Wire Colour
|
What it does
|
|
D0 pin
|
Pin D2
|
Orange
|
Sends the rain signal to Arduino
|
|
VCC pin
|
5V pin
|
Red
|
Powers the sensor
|
|
GND pin
|
GND pin
|
Blue or Black
|
Completes the circuit
|
|
- (LED)
|
Pin D13
|
Green
|
Lights up the alarm LED
|
How Does the Rain Alert Circuit Work?
Here is what happens step by step when a raindrop falls on the sensor. This is the science behind the project:
Step 1: Rain hits the sensing pad
The black stripey pad has tiny copper tracks running across it. When water lands on it, the water connects these tracks because water conducts electricity. This drops the electrical resistance on the pad.
Step 2: The comparator board sends a signal
The small blue board (comparator board) reads the change in resistance. When it detects rain, it pulls the D0 pin LOW (close to 0 volts). When dry, D0 stays HIGH (close to 5 volts). You can turn the small dial on the board to change how sensitive it is.
Step 3: The Arduino reads pin D2
The Arduino checks pin D2 every 300 milliseconds (about 3 times per second). LOW means rain is detected. HIGH means no rain. This is done using the digitalRead() command in the code.
Step 4: LED turns on and a message appears
When rain is detected, the Arduino turns on the LED using digitalWrite(ledPin, HIGH). At the same time it sends the message "RAIN DETECTED" to your laptop's Serial Monitor screen. When it is dry, the LED turns off and "NO RAIN" is printed instead.
The Code - Copy This into Arduino IDE:
// Rain Sensor + LED (Pin 13)
const int rainPin = 2; // D0 from sensor const int ledPin = 13; // LED
void setup() {
pinMode(rainPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int rainState = digitalRead(rainPin);
// Most sensors: LOW = Rain detected
if (rainState == LOW) {
digitalWrite(ledPin, HIGH); // LED ON
Serial.println("RAIN DETECTED");
} else {
digitalWrite(ledPin, LOW); // LED OFF
Serial.println("NO RAIN");
}
delay(300);
}
Fun fact: The delay(300) command tells the Arduino to wait 300 milliseconds between each check. Try changing it to delay(100) to make it check 10 times per second instead!
How Can You Use This for Your School Project?
This rain sensor Arduino project is ideal for school science exhibitions, STEM assignments, and holiday project work. Here is a simple step-by-step guide for kids and parents to follow together:
Step 1: Upload the Code
Download and open the Arduino IDE app on your laptop (it is free at arduino.cc). Copy the code from Section 4 above. Connect the Arduino to your laptop using a USB cable. In Arduino IDE, select Tools > Board > Arduino Uno and select the right port. Then click the Upload button (the arrow icon).
Step 2: Open the Serial Monitor
Once the code is uploaded, go to Tools > Serial Monitor in Arduino IDE. Make sure the baud rate is set to 9600 at the bottom right. You should see "NO RAIN" printing on screen every 300ms.
Step 3: Test It with Water
Gently drip a few drops of water onto the sensing pad. Watch the LED light up and the Serial Monitor print "RAIN DETECTED". Dry the pad with a tissue and see it switch back to "NO RAIN". That is your rain alarm working!
Step 4: Prepare Your Project Report
A great school project report covers: the problem you are solving, the components you used, how the circuit works (use Section 4 above), your test results, and ideas for what you could add next. Use the wiring table from Section 3 as a neat diagram in your report.
Ideas to Make Your Project Stand Out:
- Add a buzzer to pin 8 so it beeps when rain is detected
- Add an LCD screen to display the rain status message
- Add a servo motor that closes a pretend window when rain starts
- Use the millis() function to count and display total rain time
Exhibition tip for kids: Bring a small spray bottle to your school exhibition stall. Spray a tiny mist on the sensor pad to show your audience the LED light up in real time. It always gets a great reaction!