Trace: ya_llego_la_luz

Ya llegó la luz

Where I live, power outages are common… so when they happen I usually go to my father's home to make one of my “surprise visits”. But I always want to know when the power is restored. The only way is back to my home again… Previously I made a Nagios server pinging to the public IP of my wireless antenna… but I changed to a new provider without public IP address… I don't want to pay for one… almost I think they don't sell it.

I have one old RPI3 with some problems… For example WiFi is not working but I attached an USB dongle that make the work… I also have one USB dongle for a 3G modem, is a Huawei E153.

With the above on my hands I could make my trick… I connected the RPI to an outlet with surge protection but not battery support. So the idea is to put on crontab an alert that can send to my cell phone one SMS indicating that the power was restored.

I used GAMMU to send the mensajes, some basic instructions.

GAMMU installation/configuration

Choose one user capable to handle dialout devices:

sudo apt-get install gammu
sudo usermod -aG dialout em1069
touch /home/em1069/gammu.log
chown em1069:em1069 /home/em1069/gammu.log
gammu identify

Run last command as the choosen user, that will show to you two things, your user have the correct permissions and the device to configure GAMMU. Create $HOME/.gammucr and put something similar… remember that every 3G modem is different, but for Huawei E153 are:

[gammu]
port = /dev/ttyUSB0
model = at
connection = at19200
commtimeout = 60
synchronizetime = no
logfile = /home/em1069/gammu.log
logformat = textalldate
use_locking = yes
gammuloc =

Now create a script on $HOME/mensaje_llegolaluz.sh with the following content (replace the phone number with your phone number):

?=""
while [[ $? != 0 ]]
do
 echo "Ya llego la luz" | /usr/bin/gammu --sendsms TEXT "+50686609000"
done

So that script will try to send the message until could do it!

Finally add to the crontab the following:

@reboot /bin/bash /home/em1069/mensaje_llegolaluz.sh

TADAAAA! Try to disconnect your RPI from electric outlet and connect again…

Example

ya_llego_la_luz.txt · Last modified: 2024/06/22 13:04
Public Domain Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain