In Part 1 of this blog post, I described a problem I’ve been facing with my internet service, and the desired solution – a gizmo that would reboot my cable modem when the internet connection was down.
The first thing I got was a PiRelay from SB Components. This nifty HAT has four relays that will happily turn on and off a 110v or 250v load. The site claims 7A @ 240V, more than enough for all of my network gear. See image below, left.
![]() |
![]() |
Next I needed some way to put this in a power source. Initially I thought I’d get a simple power strip with individual switches on the outlets. I thought I could just connect the relays up in place of the switches and I’d be all set! So I bought one of these (above right).
Finally I just made a little junction box with four power outlets, and wired them up to the relays.
The software to control this is very straightforward.
- It turns out that the way Microsoft checks for internet connectivity is to do a get on “http://www.msftncsi.com/ncsi.txt”, and that returns the text “Microsoft NCSI”. OK, so I do that.
- I also made a list of a dozen or so web sites that I visit often, and I make a conn.request() to them to fetch the HEAD.
If internet connectivity appear to be not working, power cycle “relay 0”, which is where my cable modem is running. And this is a simple cron job, runs every 10 minutes.
Works like a champ. Another simple Raspberry Pi project!
If you are interested, ping me and I’ll post more details. I intend to share the code for the project soon – once I shake out any remaining little gremlins!
Hello amrith,
I found your project and it is interesting. Can we talk on email and i’ll explain my problem about this??
Thanks
LikeLike
Absolutely, happy to correspond with you on email and collaborate. My email address is on the “About” page.
Thx
LikeLike