AE6PS

  • Increase font size
  • Default font size
  • Decrease font size

APRS Status iGoogle Gadget and Monitor Script

E-mail Print PDF

Since I hardly ever drive my truck, I've had problems with dead batteries on some of those occasions I do have to drive it.  Partly, these were due to the original batteries being beyond their five year life expectancy.  Mostly they were due to the infrequent use.  I tried to solve the problem by hooking up a trickle charger, and this mostly solved the problem, but it had it's own problems.  The charger worked whenever I checked it, until I needed to drive the truck.  I finally got around to installing a couple of Optima Yellow Tops and I thought my battery woes were through, but then the outlet the charger was plugged in to lost power and the charger circuitry drew enough power from the truck that it drained the battery before I noticed.

The truck has an Tracker2 APRS tracker installed, which is currently sending the battery voltage in the status text, so I began thinking about how I could use this.  Looking at the status via one of the many APRS web interfaces was an option, but not a very good one.  It would work fine until I forgot to check.  What I needed was something I would see every day or, better yet, something that would send me a text message when the voltage was below a threshold.  Since I had just written an iGoogle Gadget to display the embedded APRS map from aprs.fi, I thought I'd start there.  I couldn't find an easy way to get just the status text from any of the APRS map displays.  Years ago, I played around a little with the APRS World back end, and I began to look into this again.  There are several ways to get APRS data using APRS World.  One is using the web map interface, another is via direct connection to the APRS World MySQL database, but the one that piqued my interest was the collection of pages that turn APRS packet data from their database into CSV (Comma Separated Variable) files, which are easy to get via HTTP and easy to parse via any descent language.  I wrote a quick PHP page that would request the status in CSV format for a specified call sign from APRS World, parse it, and display the status, packet time stamp, and how long ago the packet was heard.  This page is loaded by a small iGoogle Gadget (available here) that displays it in a small box on my iGoogle home page.  Now, I see the status of my truck every time I browse the web.

After completing this, I decided receiving a text message any time the voltage dropped below a threshold would be even more useful.  Modifying the PHP script to spit the status out on STDOUT was my first thought, but running PHP on the command line always feels a little funny, so I decided to write it in Perl instea |d.  I don't do a lot of programming, so I like to exercise those muscles when I get a chance.  I wrote the script in Unix style: do one thing and do it well.  Instead of worrying about determining if the voltage is too low and sending a text message, it just outputs the status on the command line.  It is up to the user to do something with that.  I ended up writing a rather complicated one-line bash script that compares the voltage and sends an e-mail to my phone if it is too low.  This script was added to my crontab, and set to run every morning at around 07:00 local time, right before I leave for work.  That way, if I get notified that the voltage is low, I can swing by the truck on the way out the door and plug the charger back in, or whatever I need to do to get it charging again.  If the problem isn't easily fixed, I have enough reserve voltage to put it off until I get home.  Either way, I know about it before the voltage gets dangerously low.