Go Down

Topic: Lion battery backup that sends sms when power lost (Read 981 times) previous topic - next topic

The_Knight

May 23, 2013, 10:47 pm Last Edit: May 23, 2013, 11:00 pm by The_Knight Reason: 1
Hello,

I'm building an alarm to send a text message when the AC-power fails. the problem I have,, When power is fails the alarm send  the SMS  each loop endlessly until power is restored.

I want it to send only one text-message when the power fails and happy one when power is restored. B  :smiley-red:

AC power is measured via pin 2 going incoming stream before "battery charger module"


The Alarm make a restart when it go to backup power because its a small powerdip between AC power and batterypower but when its go from AC to Battery its no dip so it dont work with "do this one time"


Code: [Select]
 
check = digitalRead(Powercheck);  \\ Reading pin 2, if AC = Power on 5v+
 if (check == LOW) {
   
                   lcd.setCursor(0,0);
                   lcd.print("Power Fail");
                   lcd.setCursor(0,1);
                   lcd.print("Skickar SMS");
                   lcd.setCursor(0,1);
                   lcd.print("+46706XXXXXXXX");
                   
                   sms.SendSMS("+46706xxxxxxx", "Warning! Power FAIL!");
                             
                   delay(3000);
 
                      }
                     
 else {
                   lcd.print("Power Online");
                   lcd.setCursor(0,1);
                   lcd.print("");
                   delay(400);
                   lcd.clear();
 }
 

RudiAhlers

This is untested but will give you an idea of what todo

In your code, before void.setup() add something like:

Code: [Select]
char Electricity = 1;

Then, add another if() statement around the current one as such:

Code: [Select]

if(Electricity == 1)
{
  // run code to send SMS
}else{
// do nothing;



Lastly, in the if statement you have, add the following to the if and else parts respectively:
Code: [Select]
char Electricity = 0;

Code: [Select]
char Electricity = 1;

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy