browser icon
You are using an insecure version of your web browser. Please update your browser!
Using an outdated browser makes your computer unsafe. For a safer, faster, more enjoyable user experience, please update your browser today or try a newer browser.

SMS Power Failure Notification

Posted by on April 12, 2010

We get frequent power failures at home due to ( our neighbor overloading his sockets and playing alot with electricity ) i setup this small system to notify me when power goes off and returns, unfortunetly i had this setup months back but due to a hardware failure i lost all settings.
Last night i decided its time to rebuild my setup again from scratch and this time document it ๐Ÿ™‚

My Setup:
1-eeepc 900 netbook running Debian lenny

2-APC UPS 1000 with USB connection

3-Sony Ericsson K800i mobile ( Viva line ) with USB Cable



Step 1:
first step is to connect the mobile USB cable to the laptop & configure gnokii
These are the changes i made:

# For the Linux USB cables you will need one of the following settings (or
# similiar)
# port = /dev/ttyUSB0
# port = /dev/tts/USB0
port = /dev/ttyACM0
# the last one will work only with AT driver. The correct setting should be
# given in the dmesg output.

# mode use:
model = AT

# For Bluetooth and AT driver use the following setting
connection = serial

The rest is default.


onfig : Linux, bluetooth connection
port = /dev/ttyUSB0
model = AT
connection = serial

To test the connection :

echo "TEST" | /usr/bin/gnokii --sendsms xxxxxxxx

Replace xxxxxxxx with your phone number

STEP 2: Configure apcupsd

Connect your UPS unit to the USB port on your laptop

edit /etc/default/apcupsd :


edit /etc/apcupsd/apcupsd.conf :

#set UPS Name

# Defines the type of cable connecting the UPS to your computer.


# NOTE in USB TYPE DEVICE is left blank to auto detect

# depends on your preference

the rest is default settings.
test the setup by disconnecting the main power from the UPS unit you should get a warning when the plug is removed and when its replaced back

STEP 3:Sending the SMS notifications

in /etc/apcupsd directory there are 4 small scripts that are used to send out notification emails : onbattery, offbattery, commok, commfailure
the first two are used for power failures and the latter two are for connectivity problems with the usb port.
you need to add one line to these scripts since they are all the same except for the message.

in this example i will take the offbattery script vi /etc/apcupsd/offbattery

# This shell script if placed in /etc/apcupsd
# will be called by /etc/apcupsd/apccontrol when the
# UPS goes back on to the mains after a power failure.
# We send an email message to root to notify him.

MSG="$HOSTNAME Power has returned"
echo "Subject: $MSG"
echo " "
echo "$MSG"
echo " "
/sbin/apcaccess status

#Add the following line and replace xxxxxxxx with your number:

echo "$MSG `date`" | /usr/bin/gnokii --sendsms xxxxxxxx

exit 0

Repeat the test in STEP 2 by unplugging the main power cable or simply switching off the power source feeding the UPS you should get something like this :

#when power is off
UPS_NAME Power Failure !!! Sun Apr 11 03:10:41 AST 2010

#when power is restored:
UPS_NAME Power has returned Sun Apr 11 03:10:46 AST 2010

as you see from above i spent the whole night fixing this thing ( Don’t do this at home unless u have no work next morning ๐Ÿ˜›

The use of the above setup is not limited to Power failures, you can do anything you need to be alerted about using gnokii previously i used it to notify me when a download is completed.. please don’t hesitate sharing any good ideas using sms notifications.

NOTE:SMS Charges may be applied depending on your carrier and plan

4 Responses to SMS Power Failure Notification

  1. Samuel Roger

    Thanks for the post. This is an wonderful post. You can send mms free anywhere India through the site:

  2. DrMahbob

    Thanks for the post but why you don’t use the smtp email system and use BlackBerry for example it is easier this way ๐Ÿ˜‰

  3. mjkout

    DrMahbob: Good idea but the problem is i don’t have Blackberry and if the power goes down so will the router therefore no email service will be usable at the time ๐Ÿ™‚ and besides i have lots of credit on that viva line i haven’t used ๐Ÿ˜‰

Leave a Reply

Your email address will not be published. Required fields are marked *