PingAlert is a low-power device consisting of a PlugComputer and an external buzzer. PingAlert sounds the alarm whenever the PlugComputer is unable to “ping” an external website (e.g., www.google.com
). The entire program is just 10 lines of Python code, and uses minimal external hardware.
PingAlert automatically starts running when the PlugComputer is powered up. The “normal” state is for the alarm to be off and the LED to flash once per second showing network connectivity. Upon loss of network connectivity, the LED extinguishes and the alarm will sound. PingAlert returns to normal once network connectivity has been restored.
PingAlert is even more useful in households which use the internet for telephone service (VoIP) such as Vonage or Skype. Often times the router or DSL/cable modem goes down and telephone connectivity is lost. With PingAlert, the user is notified and can immediately remedy the situation usually by simply resetting the router or DSL/cable modem. Minimizing downtime ensures continuous telephone availability via the internet.
Should the user not wish to be disturbed by the audio alarm, the buzzer can be disconnected just by removing the cable from the USB connector. The LED will continue to flash during normal network connectivity, and extinguish whenever the network connection is lost. In this way, PingAlert will not disturb valuable sleep or nap time
This project makes use of "devmem2" taken from another posting (http://plugcomputer.org/plugforum/index.php?topic=104.msg546#msg546
) on this forum. The "devmem2" program provides an easy way to write to the internal registers of the Marvell 88F6281 (the SoC inside the PlugComputer). "devmem2" was copied into /bin so it could run easily from any working directory.
The small Python program is attached to this posting ("/root/pingalert.txt"), and can be made to run automatically by placing a command in "/etc/rc.local" such as: "python /root/pingalert.txt". The program uses Python modules "time" (for sleep delay) and "subprocess" (for calls to commands), as shown on the "import" statement.
The PlugComputer schematics (http://plugcomputer.org/data/docs/sch/Sheeva-final%20Schematic.pdf
) show the USB connector power can be toggled on and off via MPP29, and the LED can be toggled on and off via MPP49. The registers to control these GPIO pins are described in Marvell document MV-S104860-00 "88F6281 Functional Specification". MPP29 is controlled via GPIO Data Out Register (offset 0x10100), while MPP49 is controlled via GPIO High Data Out Register (offset 0x10140).
Note: before writing to the GPIO Data Out Register (offset 0x10100), MPP29 must be made a GPIO since the default category is "Transport Stream" function. This is achieved by clearing MPP Control 3 Register (offset 0x1000C).
The program loops continuously trying to ping an arbitrary website, in this case "www.google.com
" (can easily be changed by editing the Python program -- merely a text file). When the ping completes successfully, the return code is zero. Should the ping fail to complete successfully, the return code will be non-zero (this could take up to 40 seconds to fail depending on other system parameters affecting ping operation).
Each time through the loop, the ping return code is examined. If it's zero, the power is removed from the USB connector causing the alarm to remain silent; in addition, the LED is made to flash for one second showing proper network connectivity. However if the ping return code is non-zero, (after about 40 seconds) the power is applied to the USB connector causing the alarm to sound; in addition, the LED is extinguished showing network connectivity has been lost. Fixing the network connection by resetting the router or DSL/cable modem will enable ping to succeed and silence the alarm.Hardware details:
The alarm used for this project is a piezo buzzer readily available from Radio Shack, part #273-068. It produces a 2.8KHz tone which can be pulsing or continuous, depending how the terminal connections are made on the bottom of the piezo buzzer. For this project, the red wire is connected to the "+" terminal, and the black wire is connected to the "pulse" terminal. Similar audio alarms could be used, provided they require less then 1.5A at 5VDC.
Attached are pictures of the piezo buzzer hookup to the USB cable.