In this tutorial, we will show you how to set up your Raspberry Pi to monitor your internet connection and save the data to view in Grafana or Google Drive.

This tutorial is great if you’re interested in monitoring how your download speed, upload speed, and ping are affected over time.
Additionally, this can help you work out what times your network may be at its peak capacity or if you’re suffering from a degraded internet connection.
To achieve this internet speed monitor, we will be showing you how to write a small Python script that interacts with a program called Speedtest CLI from Ookla.
Speedtest CLI is what our internet speed monitor will use to monitor the internet connection.
This program works by polling the popular speedtest.net service to get your ping, download speed, and upload speed.
If you would prefer to have a more full-featured speed test tracker, we recommend following our speedtest Docker guide instead. This gives you a fancy web interface to view your results while still allowing integration with InfluxDB.
Equipment List
Below are all the pieces of equipment we used to set up our Raspberry Pi internet speed monitor.
Recommended
- Raspberry Pi Amazon
- Micro SD Card Amazon
- USB Drive Amazon
- Ethernet Cable Amazon (Recommended) or Wi-Fi Amazon
Optional
- Raspberry Pi Case Amazon
This tutorial was last tested on a Raspberry Pi 5 running the latest version of Raspberry Pi OS Trixie.
Video Tutorial
You can watch the video below to learn how to set up an internet speed monitor on the Raspberry Pi.
Alternatively, check out the written version of the guide in the next section.
Pi My Life UpLoading video…Installing the Speedtest CLI
1. Before we get started with setting up the Raspberry Pi to monitor the internet’s speed, we must first make sure our Raspberry Pi is up to date.
We can update the Raspberry Pi by running the following two commands in the terminal.
sudo apt update
sudo apt upgrade -yCopy
2. We now need to install some packages so that we can add the package repository for the Speedtest CLI software.
These should already be on Raspberry Pi OS, but it does not hurt to check.
sudo apt install curl gpg lsb-releaseCopy
We will use curl to download the repository’s signing key, and gpg to convert it into a format apt can use. The lsb-release package lets us grab the operating system’s release name.
3. With the packages we need installed, we can now add the GPG key for Ookla’s Speedtest repository to the keychain.
We need this keychain to be able to download the speedtest command-line interface to our Raspberry Pi.
curl -L https://packagecloud.io/ookla/speedtest-cli/gpgkey | gpg --dearmor | sudo tee /usr/share/keyrings/speedtestcli-archive-keyring.gpg >/dev/nullCopy
4. Next, we need to add the Ookla repository to our sources list.
Without adding the repository, we won’t be able to install the Speedtest CLI on our Raspberry Pi.
You can add this repository by running the following command.
echo "deb [signed-by=/usr/share/keyrings/speedtestcli-archive-keyring.gpg] https://packagecloud.io/ookla/speedtest-cli/debian/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/speedtest.listCopy
Within this command, you will notice we use “$(lsb_release -cs)“. This bit of text allows us to insert the release name for our installation of Raspberry Pi OS directly into the command.
5. As we added a new package repository, we need to update our package list.
Updating the package list is as simple as running the following command.
sudo apt updateCopy
6. Finally, we can install the official Speedtest CLI on our Raspberry Pi from Ookla.
Use the following command to install the package on your device.
sudo apt install speedtestCopy
7. We can now test that we have installed the speedtest software to your Raspberry Pi.
Let us run the following command to start up the speedtest.
speedtestCopy
When you first run the speedtest software on your Raspberry Pi, you will be asked to agree to some terms and conditions.
To proceed past this warning, all you need to do is type in “YES” followed by the ENTER key.
Writing our Speed Test Python Script
1. Now that we have Speedtest CLI installed on the Raspberry Pi, we can now proceed to write our Python script that will continually monitor our download and upload speeds.
We can begin creating our Python script for the Raspberry Pi internet speed monitor by running the following command.
cd ~
nano speedtest.pyCopy
2. Within this file, write the following lines of code. We will explain each important section of the code, so you get an idea of how everything works.
3. These four lines define all of the libraries that we will be relying on in our script. Below, we will explain how each of these libraries will be used.
import os: The os library is used by the script to interact with the operating system itself.
For this script, we will be using this library to check if a file exists.
import re: The re library allows us to easily do regular expressions by providing a library for handling pattern searches.
We use this to find our desired values out of the data given to us from the Speedtest CLI.
import subprocess: The subprocess library is essential to this script, as we require it to be able to call another Python script (Speedtest CLI).
In our case, we will be using the subprocess library so we can launch up the Speedtest CLI software and retrieve the values returned by it.
import time: We utilize the time library so that we can record both the date and time for each call to the Speedtest CLI software.
This library is what will allow us to track our speed over a length of time.
import os
import re
import subprocess
import timeCopy
4. In this line of code, we utilize the subprocess library to launch a call to the Speedtest CLI and tell it to pipe everything from speedtest to stdout.
By using stdout.read().decode('utf-8') at the end of the call we store the response from the Speedtest CLI to our response variable and decode it to being a useable Python string.
response = subprocess.Popen('/usr/bin/speedtest --accept-license --accept-gdpr', shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8')
5. These three lines of code are fairly simple, and all do the same thing.
They use the re library to run a regular expression for a certain piece of text and find the number located next to each piece of text.
For instance, the search for ping finds “Latency: 47.943 ms” but only grabs the number that is between the text.
ping = re.search(r'Latency:\s+(.*?)\s', response, re.MULTILINE)
download = re.search(r'Download:\s+(.*?)\s', response, re.MULTILINE)
upload = re.search(r'Upload:\s+(.*?)\s', response, re.MULTILINE)
jitter = re.search(r'Latency:.*?jitter:\s+(.*?)ms', response, re.MULTILINE)Copy
6. These lines are important as we use the “.group()” function to grab the correct numbers from our regular expressions.
Using this, we will get the values we are after from the output of the Speedtest CLI software that we can write to our CSV file.
ping = ping.group(1)
download = download.group(1)
upload = upload.group(1)
jitter = jitter.group(1)Copy
7. This bit of code opens our speedtest.csv file, which sits in a folder called speedtest within your home directory. The os.path.expanduser() function swaps the ~ for your home directory, so you do not need to type in your username.
By using a+ in the arguments, we tell it that we want to create the file if it doesn’t exist, and that any new data should be appended to whatever is already in there.
Afterward, we utilize the os library to check our speedtest.csv file’s actual size in bytes.
If it is 0 bytes, the file is brand new, so we write the column headers to it first.
csv_file = os.path.expanduser('~/speedtest/speedtest.csv')
f = open(csv_file, 'a+')
if os.stat(csv_file).st_size == 0:
f.write('Date,Time,Ping (ms),Jitter (ms),Download (Mbps),Upload (Mbps)\r\n')Copy
8. Finally, we print out all our data separated by commas.
We use the time library’s strftime() function to insert both the current date and the current time into our formatted string.
After that, we insert our ping, download, and upload.
f.write('{},{},{},{},{},{}\r\n'.format(time.strftime('%m/%d/%y'), time.strftime('%H:%M'), ping, jitter, download, upload))Copy
9. Below, we have included an example of what the output data will look like on the first run of our code.
Date,Time,Ping (ms),Jitter (ms),Download (Mbps),Upload (Mbps)
04/29/21,06:28,18.32,1.21,23.30,7.78
10. Once you have finished writing your code, it should end up looking like what we have displayed below.
import os
import re
import subprocess
import time
response = subprocess.Popen('/usr/bin/speedtest --accept-license --accept-gdpr', shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8')
ping = re.search(r'Latency:\s+(.*?)\s', response, re.MULTILINE)
download = re.search(r'Download:\s+(.*?)\s', response, re.MULTILINE)
upload = re.search(r'Upload:\s+(.*?)\s', response, re.MULTILINE)
jitter = re.search(r'Latency:.*?jitter:\s+(.*?)ms', response, re.MULTILINE)
ping = ping.group(1)
download = download.group(1)
upload = upload.group(1)
jitter = jitter.group(1)
csv_file = os.path.expanduser('~/speedtest/speedtest.csv')
f = open(csv_file, 'a+')
if os.stat(csv_file).st_size == 0:
f.write('Date,Time,Ping (ms),Jitter (ms),Download (Mbps),Upload (Mbps)\r\n')
f.write('{},{},{},{},{},{}\r\n'.format(time.strftime('%m/%d/%y'), time.strftime('%H:%M'), ping, jitter, download, upload))Copy
11. You can now save the file by pressing CTRL + X, then Y, and finally press ENTER.
12. With our script now written, we need to make a folder where our speedtest.csv file will be stored. Run the following command to create this folder.
mkdir ~/speedtestCopy
13. Now that we have made the required folder, we can go ahead and test the script.
We can test our script by running the following command.
python3 ~/speedtest.pyCopy
14. Once the script has finished executing, you can then check out the results by opening up the newly created speedtest.csv.
Let’s open up this file by running the following command on the Raspberry Pi.
nano ~/speedtest/speedtest.csvCopy
15. Within this file, you should see something like what we have below. You’ll see the column headers and some rows of data.
Date,Time,Ping (ms),Jitter (ms),Download (Mbps),Upload (Mbps)
04/29/21,06:28,18.32,1.21,23.30,7.78
There are two different ways you can take this guide.
You can use InfluxDB and Grafana to store and graph your data, or make use of rclone to sync your data to Google Drive.
Using Grafana to Display Your Speedtest Data
In this section, we’ll show you how to use Grafana to graph your speed test data quickly.
Setting up InfluxDB for our Internet Speed Monitor
Before you start this section of this internet speed monitor tutorial, you will need to make sure you have installed InfluxDB V1 on your Raspberry Pi or on a separate server.
We will use this to store the data our internet speed monitor receives.
1. To start, we need to go ahead and run the following command to start up the InfluxDB command-line tool.
We will be using this tool to create a database where we will store our data.
influx -username admin -password <password>Copy
Replace <password> with the password you gave the admin user when you set up InfluxDB. If you have not set up authentication yet, I recommend following the Adding Authentication to InfluxDB V1 section of our InfluxDB guide first. Without it, anyone on your network can access your InfluxDB server.
2. Let’s now create a database called “internetspeed“.
Creating a database within InfluxDB is as easy as using CREATE DATABASE followed by the database name.
CREATE DATABASE internetspeedCopy
3. Our next step is to create a user called “speedmonitor” that we will be using to interact with our database.
Make sure that you swap out the password “pimylifeup” with something a bit more secure.
Don’t worry about privileges as we will be handling that in the next step.
CREATE USER "speedmonitor" WITH PASSWORD 'pimylifeup'Copy
4. Now assign the new “speedmonitor” user all privileges to our “internetspeed” database.
GRANT ALL ON "internetspeed" to "speedmonitor"Copy
5. With the database created, quit out of the tool by using the following command.
quitCopy
6. The last thing we need to do is install the Python library we need to interact with our InfluxDB database.
sudo apt install python3-influxdbCopy
Saving our Speed Monitor Data to our InfluxDB
1. Now that we have our InfluxDB database created, let’s begin adding data into it by creating a new Python script.
This script will be similar to the one we created earlier, so we will only explain the new things that we are doing.
rm ~/speedtest.py
nano ~/speedtest.pyCopy
2. To start off this file, we need to import all the Python libraries we need.
import re
import subprocess
from influxdb import InfluxDBClientCopy
As you can see, we have removed both the “os” and “time” libraries.
Both of these libraries are no longer needed as we don’t need to interact with files, and Influx automatically timestamps data.
We now import the “InfluxDBClient” client, which we will be using to interact with our InfluxDB server.
3. Our next step after importing packages is to call the Speedtest CLI and process the data.
By the end of this code block, we will have just the data that we are after.
response = subprocess.Popen('/usr/bin/speedtest --accept-license --accept-gdpr', shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8')
ping = re.search(r'Latency:\s+(.*?)\s', response, re.MULTILINE)
download = re.search(r'Download:\s+(.*?)\s', response, re.MULTILINE)
upload = re.search(r'Upload:\s+(.*?)\s', response, re.MULTILINE)
jitter = re.search(r'Latency:.*?jitter:\s+(.*?)ms', response, re.MULTILINE)
ping = ping.group(1)
download = download.group(1)
upload = upload.group(1)
jitter = jitter.group(1)Copy
4. Now here is where things get a little bit different. We need to format that data into a Python dictionary.
The reason for this is that the library expects the data to be in a JSON-like format.
speed_data = [
{
"measurement" : "internet_speed",
"tags" : {
"host": "RaspberryPiMyLifeUp"
},
"fields" : {
"download": float(download),
"upload": float(upload),
"ping": float(ping),
"jitter": float(jitter)
}
}
]Copy
Here we set up our dictionary with how InfluxDB expects the data. We gave the measurement a name, “internet_speed“.
We also set a tag called “host” to allow us to separate this out if we decide to handle multiple devices in the same database.
Next, we pass in the fields, which are the download speed, upload speed, and ping that we retrieved in the previous bit of code.
We wrap our download, upload, and ping variables in the float() function to convert them from a string to a number.
If we don’t use the float() function, Grafana will see these as strings and not interpret them correctly.
5. With all the data we need now on hand, we can now proceed to start using InfluxDB.
The first thing we need to do is to instantiate the InfluxDBClient library and pass in our connection details.
We only pass in the first five parameters for this function: the host, port, username, password, and database name.
If you want to see what data can be set, then you can view the official InfluxDB Python documentation.
client = InfluxDBClient('localhost', 8086, 'speedmonitor', 'pimylifeup', 'internetspeed')Copy
If you are using an InfluxDB server that is not located on your Raspberry Pi, make sure you switch “localhost” with its IP address.
Also, you will need to change “pimylifeup” to the password that you set up earlier in the guide.
6. With a connection now made to our InfluxDB server, we can now write our data point to the server by adding the following line of code.
client.write_points(speed_data)Copy
7. That is all we need to do to pass data to InfluxDB.
When you have finished typing in all the code the file, it should end up looking like what we have below.
import re
import subprocess
from influxdb import InfluxDBClient
response = subprocess.Popen('/usr/bin/speedtest --accept-license --accept-gdpr', shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8')
ping = re.search(r'Latency:\s+(.*?)\s', response, re.MULTILINE)
download = re.search(r'Download:\s+(.*?)\s', response, re.MULTILINE)
upload = re.search(r'Upload:\s+(.*?)\s', response, re.MULTILINE)
jitter = re.search(r'Latency:.*?jitter:\s+(.*?)ms', response, re.MULTILINE)
ping = ping.group(1)
download = download.group(1)
upload = upload.group(1)
jitter = jitter.group(1)
speed_data = [
{
"measurement" : "internet_speed",
"tags" : {
"host": "RaspberryPiMyLifeUp"
},
"fields" : {
"download": float(download),
"upload": float(upload),
"ping": float(ping),
"jitter": float(jitter)
}
}
]
client = InfluxDBClient('localhost', 8086, 'speedmonitor', 'pimylifeup', 'internetspeed')
client.write_points(speed_data)Copy
8. Save the file by pressing CTRL + X, followed by Y, then ENTER.
9. Before we move on to Grafana, run the script once so that it creates the internet_speed measurement in your InfluxDB database. It will take around 30 seconds while the speed test runs.
python3 ~/speedtest.pyCopy
If the script finishes without errors, it stores the results in your database.
Viewing our Internet Speed Data in Grafana
Our next step is to get this database to show up in Grafana.
Before beginning this section, you must make sure that you have Grafana set up on your Raspberry Pi or a separate device.
Grafana is the tool that we will be using to graph and visualize all our data.
1. Once you have Grafana set up, you can proceed with this tutorial by opening up its web interface.
If you are unsure where this sits, then go to your Raspberry Pi’s or server’s IP address, followed by the port :3000.
IPADDRESS:3000
2. Within the Grafana web interface, we need to add a new data source.
You can do this by hovering over the cog in the sidebar (1), followed by the “Data Sources” menu option (2).

3. On this page, you will need to click the “Add data source” button.

4. On the “Add data source” page, you need to find and click InfluxDB located under “Time Series Databases“.

5. Now we are required to enter the details of your InfluxDB installation.
First, enter the URL for InfluxDB (1). In our case, this is on the same Raspberry Pi that we are running the software on. If you are doing the same, then use the following URL. Grafana only shows this address as a hint, so you will need to type it in.
http://localhost:8086

Next, scroll down to “InfluxDB Details” and enter our database details (1).
If you have followed our guide exactly, the “Database” should be set to internetspeed, and the “User” should be speedmonitor. The “Password” is the one you specified, which would be pimylifeup if you used our example.
Once you have set all the required information, click the “Save & test” button (2) at the bottom of the page. You should see a message saying that the data source is working.

6. The next step is to create a dashboard to display this data.
Click the + button in the top-right corner of the screen (1), then click “New dashboard” (2).

7. On the right side of your new dashboard, click “Panel” to add a panel to it.

8. Within the new panel, click the Configure visualization button.

9. We can now set up the graph to read from our database. Grafana will already have selected our InfluxDB data source.
In the “FROM” row, click “select measurement” (1), then select our measurement name, which in this case is “internet_speed” (2).

10. With the measurement set, we now need to set the field data we want to observe. Click the text “field(value)” in the “SELECT” row (1).
From here, select “download“, “upload“, “ping” or “jitter“. For this guide, we will be starting with “download” (2).

11. Next, we want Grafana to treat each result as a distinct individual result. Click the + button at the end of the “SELECT” row (1), then click “distinct” (2) in the “Aggregations” list. This replaces the default mean().

12. Let’s give this data a better name so that we can understand it more easily. Type a name into the “ALIAS” box (1). For example, with the download speed, we set the name “Download Speed“.
Now click the “Add query” button (2) and repeat steps 9 to 12 until you have all three fields (download, upload, and ping) added to the graph.

13. On the right side of the screen, click “All visualizations” and then “Time series” to bring up the options for this graph.
In the “Title” box under “Panel options” (1), type in what you want to be displayed above the graph. In this example, we used the title “Network Speed“.
Once that is done, save the dashboard by clicking the Save button (2) in the top right corner of the screen.

14. Give a name to your dashboard (1). This name can be anything you want. We called ours “Network Speed Monitor“.
Now save this new dashboard by clicking the “Save” button (2).

15. With everything done, you should now be able to see your data displayed in a graph. It will fill out as your speed monitor script runs over the next few hours.

Automating your Speed Monitor script with Grafana
Automating your script to run periodically is a reasonably straightforward process.
1. The easiest way to automate your script to run every so often is to make use of the crontab.
You can modify the crontab by running the following command on your Raspberry Pi.
crontab -eCopy
If you are asked which editor you want to use, we recommend selecting nano, as it’s the easiest to use.
2. Within this file, add the following cronjob to the bottom.
This cronjob will run every 30 minutes. If you want to work out a different timing, we recommend that you make use of our Crontab generator.
*/30 * * * * python3 /home/<USERNAME>/speedtest.py
As you can see, this is an effortless way of getting your internet speed tested regularly and does not require you to run the script manually.
3. Once done, you can save the file by pressing CTRL + X, then Y, followed by ENTER.
The crontab will update automatically and begin running your script immediately.
Uploading your Internet Speed Data to Google Drive
In this section, we will show you how to automatically sync your data with your Google Drive account.
Preparing Rclone for the Speed Monitor Data
1. Before you begin this section, you must have Rclone installed and configured to connect with Google Drive.
If you haven’t set this up yet, follow our guide on installing and configuring Rclone. When you get up to the “Connecting to a Remote using Rclone” section, make sure you select gdrive and follow the steps to set it up. It’s a pretty straightforward process.
Make note of what you set the remote name to, as we will need it in the next step. In that tutorial, we set our name to “pimylifeup Rclone“, but we recommend using something that explains the service better, such as “gdrive“
2. Now we can test that we can copy our speedtest folder to Google Drive. This command will copy our speedtest folder to a folder named speedtest on Google Drive. If the folder doesn’t exist, it will be created. Make sure you replace <REMOTE_NAME> with the name of your Rclone remote.
rclone copy ~/speedtest <REMOTE_NAME>:speedtest --progressCopy
Automating the Raspberry Pi Internet Speed Monitor for Google Drive
1. The next big thing to do with your Raspberry Pi Internet Speed Monitor is to automate it.
To automate it, we will write a simple bash script. Crontab will run this script routinely.
Begin writing the bash script by running the following command on your Raspberry Pi.
nano ~/speedtest.shCopy
2. Within this file, we want to enter the following lines. Make sure you replace <USERNAME> with your Raspberry Pi’s username and <REMOTE_NAME> with the name of the Rclone remote.
#!/bin/bash
python3 /home/<USERNAME>/speedtest.py
/usr/bin/rclone copy /home/<USERNAME>/speedtest <REMOTE_NAME>:speedtestCopy
3. Now save the file by pressing CTRL + X then Y and then finally ENTER.
4. Before we set up the crontab for our bash script, we must first give the script execution privileges.
We can achieve this by running the following command within the terminal.
chmod +x ~/speedtest.shCopy
5. Now with everything done, we can finally move on to setting up the crontab.
Begin editing the crontab by running the following command on your Raspberry Pi. If you are asked which editor you want to use, we recommend selecting Nano (typically number 2).
crontab -eCopy
6. Add the following line at the bottom of the file. Make sure you replace <USERNAME> with your Raspberry Pi username. This line tells crontab to run our bash script once every hour.
If you want to change the behavior of the crontab, you can look at our Crontab generator to work out your desired values.
0 * * * * /home/<USERNAME>/speedtest.sh
7. You should now have your speed test monitor up and running with the script updating your speedtest.csv file on an hourly basis.
Stopping the Internet Speed Monitor
1. If you no longer want your Raspberry Pi to test your internet speed, first remove the line you added to the crontab.
Run the following command, delete the line that runs speedtest.py or speedtest.sh, then save and quit by pressing CTRL + X, then Y, followed by ENTER.
crontab -eCopy
2. You can then uninstall the Speedtest CLI and remove Ookla’s package repository by using the following commands.
sudo apt remove speedtest -y
sudo rm /etc/apt/sources.list.d/speedtest.list /usr/share/keyrings/speedtestcli-archive-keyring.gpgCopy
Your results are left in the speedtest folder in your home directory, or in your InfluxDB database if you followed the Grafana section.
Conclusion
By the end of this Raspberry Pi internet speed monitor tutorial, you should have your Raspberry Pi automatically running internet speed tests on your connection and storing the results in InfluxDB for Grafana or uploading them to Google Drive.
If you have any thoughts, feedback, or anything else, leave a comment below.


Would it be possible for it to push a pushbullet notification or something along the lines
It would be possible, but you will need to do a fair bit more programming to have it communicate with the Pushbullet API.
can i do this local on my pi ? (no gmail connect)
Hi,
Yes you can, there is no need to implement the final stages of the tutorial. It will just write to the local csv file instead.
Cheers,
Emmet
Huge thanks for such a clear tutorial.
Was able to follow it to the letter and now have my Pi 2B+ running Pi-hole and this script to monitor my network speed.
Very much appreciated.
First coded project with the pi so apologies if my issue is something obvious. I’m having trouble with the python code as it doesn’t seem to work.
This is my issue as it shows:
File “speedtest.py”, line 16
try: if os.stat(‘/home/pi/speedtest/speedtest.csv’).st_size == 0:
^
SyntaxError: invalid syntax
Any help would be greatly appreciated.
Many thanks in advance
Hi James,
It looks like you have entered the code incorrectly which is why you are recieving the syntax errors.
Cheers,
Emmet
Nice guide, I have a Pi 2 running PiHole, OpenVPN, DNS server, DHCP server, motion detection using a PS3 eye camera and now also this. Needless to say, I love my Pi!
Hello Gus, have I have the following question: can I do the checking every 2 or 3 minutes for example? If yes, how I can set it?
Ans my issue is that I can’t send it on the google drive. I can see the information on the .csv file on my Raspberry PI 3 but I can’t see it on the google account.
Hi Andriy,
Using the “crontab.guru” website you can work out what you need to change in the cron file.
For every 2 minutes you should use the following.
*/2 * * * * /home/pi/speedtest.shAnd for every 3 minutes you should use the following.
*/3 * * * * /home/pi/speedtest.shOn the note of the gdrive problems, we are looking into this. We may have to write a tutorial on compiling the tutorial from scratch as it appears like the ID used in that application by default is being used to much.
FIXED IT!!
Hi,
rclone (https://rclone.org) is a good alternative to the gdrive library.
It’s available as a standard package and supports many other storage options besides gdrive as well.
sudo apt-get install rclone
Hi Michael,
Thank you for the suggestion, i always manage to forget about rclone.
I will work on updating the tutorial to utilize rclone instead!
Cheers,
Emmet
Please Help With this!
Having This error.
pi@pi:~ $ ./gdrive list
Failed to list files: googleapi: Error 403: Rate Limit Exceeded, rateLimitExceeded
Hi Syed,
This is an issue with google drive rate limiting you for whatever reason. We plan on looking into other services you can utilize instead as it seems to be a common issue.
Cheers,
Emmet
Hey ! Please Help!
How should i resolve this error?
pi@raspberrypi:~ $ ./gdrive list
Failed to list files: googleapi: Error 401: Invalid Credentials, authError
Hi Syed,
You have not correctly setup gdrive with valid login details.
Cheers,
Emmet
stuck at this point
Failed to list files: googleapi: Error 403: Rate Limit Exceeded, rateLimitExceeded
Hi Waqar,
That error is indicating that Google has limited you for some reason, people seem to be running into this more often and we are unsure why.
It should pass in time.
Cheers,
Emmet
Certainly not an expert in these matters, can I use Putty to so the setup ?
Hi Waqar,
Yes you can.
Cheers,
Emmet
I have a rpi running pihole constantly, can this program be run on the same unit simultaneously ?
Hi Waqar,
There is no reason why this couldnt be run on the same Raspberry Pi, there should be nothing that interferes with the behaviour of pihole.
Let us know how you get on with it!
Cheers,
Emmet
I am running it for about a week on a Raspberry with PiHole. No troubles at all
Thanks so much for this tutorial. I was able to get the speedtest script to work (my first program, BTW), but I have run into an issue installing gdrive. Here is my read out:
pi@raspberrypi:~ $ wget -O gdrive https://docs.google.com/uc?id=0B3X9GlR6EmbnVXNLanp4ZFRRbzg&export=download
[1] 9069
pi@raspberrypi:~ $ –2019-03-02 15:18:06– https://docs.google.com/uc?id=0B3X9GlR6EmbnVXNLanp4ZFRRbzg
Resolving docs.google.com (docs.google.com)… 0.0.0.0, ::
Connecting to docs.google.com (docs.google.com)|0.0.0.0|:443… failed: Connection refused.
Connecting to docs.google.com (docs.google.com)|::|:443… failed: Connection refused.
[1]+ Exit 4 wget -O gdrive https://docs.google.com/uc?id=0B3X9GlR6EmbnVXNLanp4ZFRRbzg
Any thoughts?
Hi Tyler,
It doesn’t look like that your wget call could access Googles server for some reason and the connection was refused.
We have gone ahead and changed the wget call to download the gdrive executable directly from our own CDN so please try again.
Cheers,
Emmet
Thanks SO much, Emmett! That did the trick!
Can I just say that I love reading the tutorials here at pimylifeup. For someone that is just learning Linux and working from the command line, your step-by-step tutorials (with explanations) are a Godsend. I retain what I’ve learned so much better when I know the why (and definition/abbreviations) of what I’m doing. Please keep up the good work and I can’t wait to find my next project here. 🙂
Hey Gus! Thank you so much for this Tutorial!
i am having issue in accessing that google drive would you please explain is there any other possibility that i can change the drive link and save this results on some other file or folder,
Hey Syed,
I am not quite sure what you are after? Are you having issues downloading the gdrive tool or just having issues using it?
Cheers,
Emmet
Hello,
So this is my first Rasberry Pi and Python project, and I am very very new to any sort of programming. I have gotten to the point of executing the script for the first time and I’m receiving this error. I’ve double checked my code to sample and I’m not seeing where I went wrong? Help!
This is the error I get:
pi@Caseys-raspberrypi:~ $ python ~/speedtest.py
/bin/sh: 1: /user/local/bin/speedtest-cli: not found
Traceback (most recent call last):
File “/home/pi/speedtest.py”, line 12, in
ping = ping[0].replace(‘,’, ‘.’)
IndexError: list index out of range
pi@Caseys-raspberrypi:~ $
Here is my code:
import os
import re
import subprocess
import time
response = subprocess.Popen(‘/user/local/bin/speedtest-cli –simple’, shell=True, stdout=subprocess.PIPE).stdou$
ping = re.findall(‘Ping:\s(.*?)\s’, response, re.MULTILINE)
download = re.findall(‘Download:\s(.*?)\s’, response, re.MULTILINE)
upload = re.findall(‘Upload:\s(.*?)\s’, response, re.MULTILINE)
ping = ping[0].replace(‘,’, ‘.’)
download = download[0].replace(‘,’, ‘.’)
upload = upload[0].replace(‘,’, ‘.’)
try:
f = open(‘/home/pi/speedtest/speedtest.csv’, ‘a+’)
if os.stat(‘/home/pi/speedtest/speedtest.csv’).st_size ==0:
f.write(‘Date,Time,Ping (ms),Download (Mbit/s,Upload (Mbit/s)\r\n’)
except:
pass
f.write(‘{},{},{},{},{}\r\n’.format(time.strftime(‘%m/%d/%y’), time.strftime(‘%H:%M’), ping, download, upload))
Hi Casey,
Sorry for the late reply.
Please make sure that you have the speedtest-cli tool downloaded and installed to your Raspberry Pi, from the looks of it the script is failing to run the file which is causing the issues that you are experiencing.
Cheers,
Emmet
Great tutorial, everything works perfect, thanks bro
Thank you for the tutorial. I got everything working without any issues.
I was thinking of how to expand upon this and maybe graph the data to a local RPi website. I have seen a few examples using Matplotlib, but it looks a little over my head. Any suggestions or examples you can point us to to graph this data?
Thanks
Josh
Hey Gus, I’m a huge fan of your tutorials and have done all of them so far! I When running the full python script, I got this error and don’t know how to fix it:
Traceback (most recent call last):File "/home/myusername/speedtest.py", line 23, in
f.write('{},{},{},{},{}\r\n'.format(time.strftime('%m/%d/%y'), time.strftime('%H:%M'), ping, download, upload))
NameError: name 'f' is not defined
Hopefully you can figure out what is wrong and reply back to me!
Hi Tom,
I am unable to recreate the issue, are you able to send me the contents of your speedtest.py file.
Posting here will be fine.
Getting the same error – did you get yours resolved?
Hi, this happens if you did not create the speedtest directory.
The command creates the file, but not the directory if it doesn’t exist.
mkdir ~/speedtest
and try again.
you have to use sudo
sudo python speedtest.py
Dear Gus, thank you for the nice tutorial. I think there is one error in python script in regards to the location where the .csv file should be saved. Instead of /home/pi/speedtest.csv it should be /home/pi/speedtest/speedtest.csv.
Thank you Nenad! I have fixed it up now.