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

}

Comments

author
sbayley2 made it!(author)2017-01-06

Hi Eddivine.

OK , so I'm a maker but not at all clued up on arduino.

I have a large Aquaponic system that has 3 tanks (soon to be seven) and I have twice now left the water off in one of my tanks leading to a mass death of my trout.

I am disabled and on bad days I am barely lucid so mistakes happen.

I am looking for a multi function Arduino solution to warn me when the water flow stops in my system.

I have a step up transformer I'd like to switch on in the event of a power outage and I'd like an alarm or text if one or more of my tanks are not receiving constant water flow.

Is there any chance that you could help?

(Picture is what happened this time I left the water off for 2.5days while bed bound. That is my maggot box where my Black Soldier Fly Maggots grow up as fish food.)

temp_40557209.jpg
author
ryanjblajda made it!(author)2014-07-18

Hey, eddevine, i am trying to modify this sketch to work with a PIR sensor as a motion security system and i have the PIR sensor working, but as i watch the serial window, it seems to send a message even when the pin is reading low.

author
eddevine made it!(author)2014-02-21

I think it's about 5 or six months, 10 cents per minute and $25 in your account that you draw from and it's renewable. I feel it's a cheap insurance policy. I know what you are going thru for answers, I did the same thing, finally went to Walmart got a cheap phone and jumped in. Maybe if someone else has a better plan, they could let us both know.

author
brad_mcelroy made it!(author)2014-02-21

Great write up. After the power outage last night, I want to build an alarm like this and add in a battery backup solution too. My question is about the GSM text plan. If you get the GSM shield, and then buy an AT&T gophone sim and minutes, do you have to renew/repay for it each month, or do you have a set number of texts on your account, and the refill card will keep you stocked up on texts until you use them all? I'm trying to find that info myselft, but I'm not finding a straight answer yet.

Thanks