Track Internet Dropouts, monitor ADSL bandwidth and Notify Your ISP with RPi

By on July 11, 2016
Pin It

A dream came true for all home internet connection subscriber and a hellish nightmare for the internet providers marketing departments…

If there’s one thing that’s the same about everyone’s broadband connection, it’s that it’s slow. Usually slower than it was advertised to be when you got it. But slow isn’t as irritating as sporadic, when you get constant drops and outages in your internet connection, it can drive you to frustration.

It drove one man in Washington D.C. to monitor his broadband connectionwith a Raspberry Pi, and automatically tweet Comcast when his connection drops to a fraction of advertised speed.

Another project, simpler too, is based on  speedtest-cli, a command line interface to the servers written in Python.

It’s really easy to install. Just open up a terminal window on your Raspberry Pi and type the following at the command line,

<strong>$</strong> sudo apt-get install python-pip
<strong>$</strong> sudo pip install speedtest-cli

this will install pip — a package management system for Python — if you don’t already have it installed, and then the speedtest-cli package from thepip repositories.

Once installed it’s rather easy to grab and measure your broadband speed.

<strong>$</strong> speedtest-cli
Retrieving configuration...
Retrieving server list...
Testing from Acme Broadband Provider. (XXX.XXX.XXX.XXX)...
Selecting best server based on latency...
Hosted by Foo Limited (Metropolis) [2.52 km]: 35.27 ms
Testing download speed........................................
Download: 14.47 Mbit/s
Testing upload speed..................................................
Upload: 1.46 Mbit/s

In any case, now that we have our command line tool installed, we can run it automatically using cron, which allows you to schedule commands to run at specified times (every hour), and log the output to a file.

The easiest way to do this is to create a quick script, let’s call it, which will log the date and the output of the test to a file,

date >> /home/pi/speedtest.log
/usr/local/bin/speedtest --simple >> /home/pi/speedtest.log

To format the raw data output from the script and prepare a “communication” to the ISP,  IFTTT‘s Maker Channel, introduced towards the middle of last year, comes in handy. I went ahead and created a recipe on IFTTT to take the data passed to a Maker Channel event called “speedtest” and automatically fill a Google Sheet with the output of speedtest-cli script.

The easiest way to get the data from our Raspberry Pi to IFTTT at this point is to modify the speedtest-cli-extras script. Instead of printing out the output to a log file, we’ll make a POST web request with the event name and our secret key — the key is assigned when you connect the channel — of the form,<strong>{secret_key}</strong>

with a JSON body consisting of  three values — the latency, download, and upload speeds — to be passed on to the action in the recipe.

 You will have a google drive spreadsheet with all the scheduled measurements. To check the further steps and details visit Make:

About Luca Ruggeri

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *