This project sends SMS alerts to a phone number whenever rain is detected at a monitored location. The system uses a rain sensor module to detect moisture, an Arduino Uno to process the signal, and a SIM800L GSM module to send text messages over cellular networks. The guide includes a complete wiring diagram, parts list with component values, and ready-to-upload firmware.
Builders will learn how to interface a rain sensor with an Arduino, communicate with a GSM modem via serial protocol, and implement debouncing logic to avoid false alerts. The battery-powered design with an 18650 Li-ion cell makes this suitable for remote outdoor installations where AC power is unavailable.
Wiring diagram

Gather all the parts
Assemble it in 3 steps
1. Wire the rain sensor with power off
Connect the sensing plate to its comparator board. Connect VCC to Uno 5V, GND to GND, and DO to D2. Adjust the module so DO goes low when you wet the plate.
2. Wire the modem signals
Use the two resistors as shown to lower the Uno transmit voltage. The 74AHCT125 raises the modem transmit voltage for the Uno. Put the 100 nF capacitor next to the buffer power pins.
3. Connect the two power sources
With USB unplugged and the holder empty, wire holder positive to modem VCC and holder negative to modem GND with short wires. Connect modem GND to Uno GND. Fit the capacitor close to the modem, stripe toward GND. Attach the antenna and insert an active 2G SMS SIM with PIN lock off. Use USB for the Uno and one protected cell for the modem. Disconnect both sources when done.
- Never join the positive supplies or use a two-cell series holder. Do not charge the cell in this circuit; remove it and use a proper charger.
Review all connections
1. Connections between "rain" and "Arduino"
2. Connections between "cell" and "Arduino"
3. Connections between "holder" and "Arduino"
4. Connections between "modem" and "Arduino"
5. Connections between "bulk" and "Arduino"
6. Connections between "top" and "Arduino"
7. Connections between "bottom" and "Arduino"
8. Connections between "rxbuffer" and "Arduino"
9. Connections between "bypass" and "Arduino"
Deploy the firmware
#include <Arduino.h>
#include <SoftwareSerial.h>
SoftwareSerial modem(8,9);
const char phone[] = "+639915938839";
bool waitFor(const char* token, unsigned long timeout) {
size_t n=0;
unsigned long start=millis();
while(millis()-start<timeout) if(modem.available()) {
char c=modem.read(); Serial.write(c);
n=c==token[n]?n+1:(c==token[0]?1:0);
if(!token[n]) return true;
}
return false;
}
bool sendAlert() {
if(phone[1]=='Y') { Serial.println(F("Set phone in src/main.cpp first.")); return false; }
while(modem.available()) modem.read();
modem.println(F("AT")); if(!waitFor("OK",2000)) return false;
modem.println(F("AT+CMGF=1")); if(!waitFor("OK",2000)) return false;
modem.print(F("AT+CMGS=\"")); modem.print(phone); modem.println('"');
if(!waitFor(">",5000)) return false;
modem.print(F("Rain alert: water detected.")); modem.write(26);
return waitFor("+CMGS:",60000);
}
void setup(){ pinMode(2,INPUT); Serial.begin(9600); modem.begin(9600); }
void loop(){
static bool previous=false, attempted=false, latched=false;
static unsigned long changed=0,last=0;
bool wet=digitalRead(2)==LOW;
auto now=millis();
if(wet!=previous){previous=wet; changed=now;}
if(!wet && now-changed>=5000) {latched=false; attempted=false;}
if(wet && !latched && now-changed>=2000 && now>=15000 && (!attempted || now-last>=60000)){
attempted=true;
latched=sendAlert(); last=millis();
Serial.println(latched?F("SMS accepted by modem"):F("SMS not confirmed"));
}
}Remix this project
Make it yours in one click
Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.




