Using Android to track power outages

I woke up this morning to the backup alarm on my Android phone; my regular alarm clock had not rung.

There was a simple explanation visible on my alarm clock, which was blinking "12:30"—a power outage.

So I knew when the outage had ended—half an hour ago—but not how long it had lasted. Should I be worried about the food in my fridge?

I remembered that my Android phone, the one that had rung the backup alarm—because it had a battery backup, of course— had been plugged in overnight.

Screenshot of CatLog showing changes in 'plugged' stateNot wanting to bother launching Eclipse at the moment, I quickly found a great free log viewer called CatLog in the Play Store. One minute later, I had my answer.

The system statusbar logs changes to the signal strength, power state, etc. I just filtered with the keyword "plugged" to track the power state. It was immediately clear that the outage had started around 8:06 AM and was over by 8:10—nothing to worry about.

Of course, this isn't a perfect solution for tracking power outages in general.

  1. It only works if the device is plugged in (so generally only at night).
  2. Android's system log has a very limited buffer, so this only works for brief power outages that happen shortly before the logs are checked.
  3. Opening a system log viewer and searching through it is not the easiest experience for the average user.

#1 can't be avoided. #2 and #3, however, can be solved by writing a simple app that runs a service in the background to record power state independently of the limited system log, and has a decent UI for presenting that information to the user. I'll add that to my to-do list :-)