Pages: [1]   Go Down
Author Topic: Lion battery backup that sends sms when power lost  (Read 673 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
 
 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();
  }
  
« Last Edit: May 23, 2013, 04:00:22 pm by The_Knight » Logged

Johannesburg, South Africa
Offline Offline
Full Member
***
Karma: 0
Posts: 180
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Code:
char Electricity = 1;

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

Code:
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:
char Electricity = 0;

Code:
char Electricity = 1;
Logged

Pages: [1]   Go Up
Jump to: