Monday, February 20, 2023

Eskom Loadshedding Solutions - Raspberry Pi Router "Watchdog" Project: Testing Internet Connection (Part 1)


During Eskom loadshedding especially Stage 6,  I experienced several times that my GRHub Network Internet connection was lost before or after a spate of loadshedding.  Although my LTE router was on and all the necessary lights were on and blinking there would be no Internet connection.  I do not sit and watch the connection during or after a loadshedding period, I needed a automated “watchdog” for the Internet connection.  Now I know that many modern routers can be set to automatically reboot at a certain time, but my router does not have the future and this would not solve the current problem.  I looked at several projects using different module board to get the task done.  I did not want to fork out extra money as I already had a relay module, a Raspberry Pi Zero W and other items sitting on the shelf doing nothing.  Well the Pi and a few other goodies which I had on hand was chosen for this project. 

I was looking to create a project that will sense a chosen website on the Internet.  If the Internet was up and running the Python script would tell me that the Internet connection was successful and that no further input was needed.  If the Internet was down the script would tell me that the connection to the Internet failed and will the script reboot the Router.  It will automatically turn of the power to the Router, wait one minute to turn the Router back on.  After 60 seconds the power will be turned on and the Router will power up and reboot.  I also needed a log (txt) file where the shell output can be stored.  I decided to go the txt route with an entry under Crontab.  I can check relay_final.txt for print logs with time and date stamps. The shell output txt file will provide me with all the necessary info needed to do fault finding or want to know when the Internet was off and when it returned to the on state.  

The script that I wrote will be run every 30 minutes (can be set to your liking) automatically using Crontab.  It will go through the sequence and will do the necessary IP pinging  to confirm success or failure.

I am not going to go into great detail here as the Internet has more than enough info to construct such a project.  I did however compile three videos to illustrate the use of the project.  Please note I am not a professional You Tuber and I apologize beforehand for the quality of the videos.  The left hand handled the camera and the right hand was used to activate the computer software.  I will also post the two Python scripts that I created from info sourced from various Internet websites.  The log (txt) file containing the shell output will also be made available.   I am still busy with the project and further info will be made available in another post under Testing Internet Connection (Part 2)

Here is the videos and shell outputs from the Python Script for this project.

 


(Click on images for larger view.)

 

Part 1

Part 2

Part 3


(Click on images for larger view.)

In Part 2 I will future the Phyton Script Code, running the script as a Cron Job and the final installation of the project in a cabinet and then to the GRHub Network LTE Router and Power Source.

Part 1 of this project was brought to you by ZS1I as part of the current series,  "The Eskom Loadshedding Disaster and Amateur Radio".  This is to alleviate loadshedding issues that has a detrimental effect on the amateur radio hobby.  

Previous projects in this regard:

Eskom Loadshedding - This R50.00 Scrap Metal UPS keeps the lights on! 

Eskom Loadshedding - I needed either a UPS or Backup 220v Power Unit for my desktop computer in the Shack ASAP!!

Eskom Loadshedding - Foolproof Power Backup Controller Project for your Radio, Radio Link or Repeater (Part 1)

Eskom Loadshedding - I am no Prophet of Doom!!

Eskom Loadshedding - A solar panel charge controller for all seasons....especially if you cannot find a trusted one!

Eskom Loadshedding - Load-shedding in South Africa calls for Solar Power Supply V 1

Eskom Load-shedding in South Africa calls for a Simple Inverter Power Supply in the Shack

Eskom Loadshedding - Foolproof Power Backup Controller Project for your Radio, Radio Link or Repeater (Part 2)

Eskom Loadshedding - Beat the Eskom Loadshedding Blues with this DIY Internet Router UPS Project.

Eskom Loadshedding - KISS DIY Solar Panel Charge Controller

Eskom Loadshedding killed my Home Network Router? How to prevent this from happening to other equipment in future! 

Eskom Loadshedding - Prevent equipment damage in your Home and Amateur Radio Shack when power returns after an Eskom load shedding period.

Eskom Loadshedding - Update: 220v Time Switching Relay Unit to prevent equipment damage during loadshedding or power outages.

 

Can one see Auroras (Southern Lights) in South Africa?

Aurora Australis (Southern Lights) over Simons Town. Picture: Hassaan Tanvir During a recent discussion on the "Sonsak Span Amateur Rad...