Skip to content

lizard43/routerWatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Router reboot with Raspberry Pi and Python.

My Westell DSL router locks up several times a day. Frontier customer service isn't very helpful and they end up just sending me a new router instead of helping. I now have 4 routers and all behave the same. If I pull the power plug for 10 seconds, the router reboots and then I have intenet access for a few more hours until it hangs yet again.

My solution is now to use a cheap Rasperry Pi and a relay. The Pi runs a Python script that watches for internet connectivity to drop. The Pi will toggle the normally closed relay for 10 seconds (which cuts power to the router).

These Python scripts and approach are based on work by others:

Clone this repo onto your Raspberry Pi. I'm using an older Pi 2 because I don't need a faster Pi 3 but I do want a CAT 5 wire into my router.

Edit the Pi's crontab so that the main Python script runs at reboot:

  • crontab -e
  • at bottom, add this line:
    • @reboot /home/pi/routerWatch/routerWatch.sh
  • ctrl-o to write file and press enter
  • ctrl-x to exit editor

The routerWatch.sh file writes log messages to /tmp/routerWatch.txt It will overwrite this file at each Pi reboot. This file will grow unbounded until Pi reboot, so if your SD card is low on space, beware.

I'm using a cheap relay from eBay to reset the routers power. I'm tapping into the router's 12v power line so I'm not worried about mains power.

Relay Pin Pi Pin Wire Color in my diagram above
VDC Pin 1 - 3V Red
GND Pin 6 - GND Black
IN Pin 16 - GPIO23 Green

I cut into the power supply's positive line and that is what will be toggled by the normally closed relay. I chose normally closed rather than normally open so that when the Pi is turned off, the relay will be closed and the router will act as if nothing was in the loop.

Relay Pin Power Wire Color in my diagram above
NC - Top Positive from Plug Red
Cmn - Center Positive to Router Red

FYI - This is the difference between a normally open relay and normally closed:

About

Router reboot with Raspberry Pi and Python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published