One application of a Raspberry Pi is to keep track of your broadband speed, which is a measure of the rate at which you can download and upload information through your internet connection using your computer or other internet-linked devices such as smartphones. You may want to know the broadband speed in your home so that you can identify the cause of internet problems you come across. So, without further ado, let’s get into how to use your Raspberry Pi to monitor broadband speed.
To begin, check that your Raspberry Pi is operating on its latest version. In the Python terminal, type in sudo apt-get update, and on the next line, type sudo apt-get upgrade to check for updates. Following this, you must download speedtest-cli, which is a portion of code that you can interact with as a command line interface. It communicates with the website speedtest.net to show you what your broadband speeds are.
Since speedtest-cli is not included in Raspbian, you need Python pip. Python pip allows you to install speedtest-cli from the Python Package Index, or PyPI. Usually, pip is already included with your Raspbian operating system. If you don’t have it, enter the command sudo apt-get install python-pip in your Pi.
To install speedtest-cli itself, type in sudo pip install speedtest-cli. With that done, you can write speedtest-cli or speedtest-cli --simple to receive the ping, download speed, and upload speed.
Though this point is fine for checking on broadband manually, you Pi is far from being able to monitor it on its own. You need to transform the output you get from speedtest-cli into CSV syntax to continue. Make a new file with two lines. The first should be cd ~ and second should be sudo nano speedtest.py. Next, you must put in several lines of code to Python. This section is quite extensive, so your best bet is to search up the necessary script from in-depth guides online and copy and paste it from them into your Pi. Once you done so, the input python3 ~/speedtest.py should give you back data in this format: date, time, ping, download, upload. Note that ping is measured in ms, while download and upload speeds are measured in Mbit/s.
Now, make a directory to link your data to Google Drive. You need to have the gDrive tool before move on and once you do, you can make the directory by writing gdrive mkdir speedtest. You’ll see an ID pop up, which you must take a note of. Then, type gdrive sync upload ~/speedtest [folder ID]. In place of [folder ID], put in that ID you just received without brackets. Now your Pi will be synced with Google Drive.
For the final stretch, you are going to command the Raspberry Pi to automatically monitor broadband speed at set time intervals. Make another file with nano ~/speedtest.sh, and follow this with these three lines: #!/bin/bash, python /home/pi/speedtest.py, and /usr/local/bin/gdrive sync upload /home/pi/speedtest [folder ID]. All that remains is to input three separate commands which are not part of the same code block as the previous three were. They are sudo chmod +x /hom/pi/speedtest.sh, crontab -e, and 0 * * * * /home/pi/speedtest.sh. Your Pi will note the broadband speed data every hour and Google Drive will store this information.
Now that you learned how to use your Raspberry Pi to monitor broadband speed, get going with your Raspberry Pi broadband speed monitoring today by visiting Chicago Electronic Distributors for Raspberry Pi computers and their related equipment, such as pi plates.
Comments will be approved before showing up.