Free US Shipping on orders over $150 with discount code "FREESHIP" at checkout

How To Use Your Raspberry Pi To Monitor Broadband Speed

October 08, 2020

How To Use Your Raspberry Pi To Monitor Broadband Speed

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.

Install speedtest-cli

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.

Write Code for CSV Syntax

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.

Connect To Google Drive

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.




Leave a comment

Comments will be approved before showing up.


Also in News

Using a Level Shifter With the Raspberry Pi
Using a Level Shifter With the Raspberry Pi

October 30, 2020

The parts that you connect in a circuit may not always match in their logic levels. We teach you how to use a level shifter with Raspberry Pi to fix this issue.

Continue Reading

The Different Components of the Raspberry Pi 4
The Different Components of the Raspberry Pi 4

October 15, 2020

The Raspberry Pi 4 is the latest model of the Pi computers. We cover the different components of the Raspberry Pi 4 to give you an idea of its capabilities.

Continue Reading

Ways To Use Raspberry Pi in the Classroom
Ways To Use Raspberry Pi in the Classroom

September 21, 2020

Raspberry Pi computers are useful for teaching students about computers and electronics. Discover ways to use Raspberry Pi in the classroom here.

Continue Reading