internet alarm

whens the internet coming back?

david marsh


Recently we’ve had some internet outages.

Whenever the internet would go down I’d be asked by nearly everyone “Is the internet down?” and “When’s it coming back?”

Currently undergoing an internet outage

Well the nbn has been out most of the day

I can’t automate the answer to the second question about when it’ll be back1 but the first I certainly can. Previously the we’d check a light on the router, but it’s hard to see, and where’s the fun in that when you can have an over-the-top solution instead?

So, in the spirit of an almost useless device, I made an “The Internet is (still) down!” flashy light thing using an old Raspberry Pi, a PiFace IO board and a cheap kids toy.

First step was to install the older Raspberry Pi OS Lite (Legacy) version, as this Pi is getting old in the tooth. As the Pi is basically doing nothing for the majority of the time, there’s no point using a higher spec Pi for this job. Another advantage is of this Pi is that it is hardwired network only, providing a more reliable connection than wifi.

One day I may replace it with a Raspberry Pi Pico, but for now this is good enough.

First the standard stuff; make sure the PiFace board is installed, copy the OS to the SD Card, connect the power and network, and confirm I could ssh to the device.

I updated the OS and installed the needed software:

apt-get update
apt-get upgrade
apt-get install pifacecommon pifacedigitalio

I then downloaded and ran the test program from the PiFace github examples.

The light stared blinking and everything was working as expected.

Somewhere I’d gotten a cheap orange flashing light and it was perfect for this as it’s way over the top. Previously I’d swapped out the switch with wires for using with the PiFace board and now I finally had an excuse to use it in a “real” project. So I connected the wires to relay0 in the PiFace board, connecting one wire to common and one to normally open. It doesn’t matter which way around the wires are.

Here’s the very simple code that I use to turn the light on:

import pifacedigitalio
if __name__ == "__main__":
    pifacedigital = pifacedigitalio.PiFaceDigital()

and this is to turn it off:

import pifacedigitalio
if __name__ == "__main__":
    pifacedigital = pifacedigitalio.PiFaceDigital()

Testing went well; light on, light off, light on, light off.

I then added a job to ping my ISP every 2 mins in cron. If the ping is successful it runs, otherwise it runs

*/2 07-22 * * * if ping -c2 nnn.nnn.nnn.nnn >/dev/null 2>&1 ; then /home/rdm/ ; else /home/rdm/ ; fi

So we don’t wake everyone up in the middle of the night, the cron script only runs between 7am and 11pm. At 11pm the off job will run just to make sure the light is off:

00 23 * * * /home/rdm/

If the Pi can’t ping my ISP, everyone will be able to quickly tell with this helpful, highly visible and stress-inducing light:

flashing orange light

Now I just need to have it answer “When’s it coming back?” with “I don’t know” and I’ve automated 90% of the home admin work I do.