Introduction: Sump Pump Alarm

I have had so many times over recent storms, have a sump pump fail, maybe thru paranoia I assembled this sump pump notification system, so even if I’m away from home I will get a message on my iphone5 if flooding begins to occur.

Parts used
arduino uno rev 3
sim900 gsm/gprs shield
one 10k resistor
sim card (I used an at&t go phone card from Wal-Mart)
misc wood, brackets, and conduit I had laying around (see photos)


code

#include <SoftwareSerial.h>



SoftwareSerial mySerial(7, 8); //gprs shield attached to pins 7 and 8 for software serial connection



const String phoneNumber = "+1xxxxxxxxxx"; //the phone number of the phone to send the text message to, remember to include the country code before the number

const int sensorPin = 2; //the water sensor is attached to pin 2

boolean flooded = false; //set the flooded variable to false

boolean messageSent = false;



void setup(){

  mySerial.begin(19200); //19200 is the GPRS baud rate, this must be fixed

  //Serial.begin(19200);

 

  pinMode(sensorPin, INPUT);

  SIMpower();

  delay(20000);

}

void SIMpower()

// software equivalent of pressing the GSM shield "power" button

{

  digitalWrite(9, HIGH);

  delay(1000);

  digitalWrite(9, LOW);

  delay(5000);

}

void loop(){ //we loop through this area

  if (digitalRead(sensorPin) == HIGH){ //if the sensorPin is high, current is being passed into it, so the sensor must be submerged

    flooded = true; //the basement is therefor flooded

  } else if (digitalRead(sensorPin) == LOW){ //otherwise if it has no current

    flooded = false; //the sensor isn't submerged

    messageSent = false; //we can reset the messageSend, so that if it becomes submerged again, we can end another text message

  }

 

  if ((messageSent == false) && (flooded == false)){ //if we havent yet sent a message, and the sensor is submerged

    sendTextMessage(phoneNumber, "Your basement is flooding [Arduino]"); //we send the text message

    messageSent = true; //we set messageSent to true so that we don't keep sending text messages (this woulld cost a lot of money)

  }

}



void sendTextMessage(String phone, String data){ //sends a text message to phone, containing data

mySerial.print("AT+CMGF=1\r");    //Because we want to send the SMS in text mode

delay(100);

mySerial.println("AT + CMGS = \"" + phone + "\"");//send sms message, be careful need to add a country code before the cellphone number

delay(100);

mySerial.println(data);//the content of the message

delay(100);

mySerial.println((char)26);//the ASCII code of the ctrl+z is 26

delay(100);

mySerial.println();

delay(5000);                                     // give module time to send SMS

SIMpower();                                   // turn off module

}