This script will check if we get a response from google or not and from that we can determine if our internet connection is available or not. By checking our connection we can use it with other scripts and logics to do some interesting things.
For example in this script if we are not connected to internet then we will turn on a led; else we won't. If we lose connection even once we'll light up led even after restoring connection. By this way we can determine if our internet was ever lost while this script was running.
git clone https://github.com/Onnesok/check_internet_connectionFirst check if python-rpi.gpio is installed or not. so, for that open your terminal and write:
pip install RPi.GPIONow connect led positive part to raspberry pi GPIO pin 18 and negative to ground. you're done....
After that you're good to run the script.
To run it open your terminal and write.
cd check_internet_connection
sudo python3 internet_connection_checker.py