Rain Detected then GSM Module Send SMS using Arduino:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(9, 10); //(RX,TX)
int d=0;
void setup() {
mySerial.begin(9600);
Serial.begin(9600);
pinMode(11,INPUT); //FOR DIGITAL INPUT
pinMode(A0,INPUT); //FOR ANALOG INPUT
delay(50);
}
void loop() {
int sensorReading = analogRead(A0); //value detected Raindrop Sensor
if(sensorReading<500) // when raindrop sensor detect analog value then value
// will be reduce
{
Serial.println("Its Raining Outside");
SendMessage(); //Send Sms to Gsm module
while(analogRead(A0)<800); //HOLDING STATE UNTIL RAIN STOP
}
else if((sensorReading>500)&&(sensorReading<800)) // this is for rain Warning
{
Serial.println("Rain Warnigitng");
}
else if(sensorReading>800) //when not raining
{
Serial.println("NotRaining");
}
delay(1000);
}
void SendMessage()
{
mySerial.println("AT+CMGF=1"); //SELECT SMS Text Mode
delay(1000);
mySerial.println("AT+CMGS=\"+91XXXXXXXXXX\"\r"); //GIVE YOUR MOBILE NUMBER
delay(1000);
mySerial.println("IT IS RAINING OUTSIDE )");
delay(100);
mySerial.println((char)26);
delay(1000);
}
Can I have the components of this??? Thanks
ReplyDelete