SMS Alert on power cycle - possible using Python ?

Hi there,

We’re currently doing a project where a Connect WAN VPN router is integrated into a kiosk which providing a bike rental service.

I would like to be able to detect a power failure to the kiosk - i.e. when the Digi router comes back from a power failure and resumes its connection to the cellular network - send an SMS to the administrator notifying about it.

I know how to send an SMS - what I’m not sure about is how to detect a power cycle that is not result of Surelink reboot or from the Web management.

Any ideas ?

Thanks and BR,

Do you have any form of UPS? Even a small 12vdc battery & charger to ride out say a 30-second power glitch?

If not, detecting a true power failure will be hard.

If you do have some power backup, then you could perhaps use one of the WAN’s RS-232 control signals as a input from a power-relay on CA power? Seeing it drop to low/non-expected, that tells the WAN that AC power has been lost. The WAN could then SMS that power is GOING - but not that it RETURNED.

Although you could perhaps create a temporary FLASH file when you see power lost, so upon restart you detect the fill exists, send the SMS and delete the file.

Hi Lynn,

Thank you very much for your quick response.

Having thought about it a bit - all I really need to know is that the unit came back up after losing power unexpectedly.

So how about a script that just sends an SMS when the unit first boots up ?
That would be enough to figure out that power was dropped for some reason.

Another idea - does the router store the clock somewhere ?
When it comes back online and syncs using SNTP it can compare to the stored clock - if the difference is too big it could determine a possible power failure.

Come to think of it, there must be a flag somewhere that is set when the unit performs a proper reboot. I imagine there must be something like that in the OS similar to what Unix OS’s have…

What do you think ?

I think the WAN VPN as a hardware RTC, so there should be no noticable time slip.

I do not think there is any flag or register or file that you could use to detect WHY the unit restarted.

If your Python script (and your people) could be disiplined enough to only reboot via some software which uses Python to trigger reboot, then at least your Python could detect “Our Graceful Reboot” verse “Some Other Reboot”.

Hi lynnl,

Thank you very much for your support -

At the moment we’ve decided not to implement anything via Python for detecting a power failure. The customer has determined it will be good enough to have an indication when the entire station goes offline (they are supposed to be online at all times).

Thanks again and BR,