The other day I came home and realized that, while I was out, we'd lost and regained ac-line power. We all know the symptoms: flashing digital clocks, computers and networks in unusual states, some lights off that were left on, and other things not quite right.
Then an obvious question popped into my head: so, for how long was the power out? The answer usually isn't critical, but sometimes you want to know, whether for food safety reasons or just plain curiosity about the power company's performance and repair service. And how do we determine how long the power has been out? Turns out it isn't easy, with today's modern electronics.
The reason is devices which rely on AC power have no way of recording the time of ac mains power loss and its return, which is distinctly different from the device being turned “off”–or what is designated as “off”–in today's electronics. In contrast, devices which do have internal battery backup have the opposite problem: they keep on running, via automatic switchover, with no way of even knowing, in most designs, when the line went down and returned.
It not hard to build a microcontroller device which would run from the AC line and also have a battery backup, have a internal clock, and monitor and note when the line power went down and returned. Of course, you'd need a display, some way for the user to enter the clock time, and also to access the power-down data. And it would have to be small and cheap, too.
I thought about this as a personal project, then said “maybe another time.” Instead I went for a low-tech, low-cost ($7), old-fashioned solution: I bought a line-powered clock (the kind with a real motor and hands), and plugged it in. Now all I have to do to know how long power was out is calculate how “wrong” this clock is. Sure, it's a only practical solution for outages up to 12 hours, but I can live with that. Just in case, I also place an ice cube in a small cup in the freezer. If the cube is melted, I know the freezer went above 0 degree C (32 degree F) for a while. Sometimes simplicity makes for a nice solution.
-x x x-