Ubidots Community

Speedtest CLI with Raspberry Pi 4 and Ubidots for gigabit internet testing

Hello all,

This is my first post, please be kind I’m new to all of this!

My goal is to use a Raspberry Pi 4 (8GB) with Speedtest CLI and Ubidots. Before you speed type… I followed the tutorial: “Test your internet speed using a Raspberry Pi + Ubidots” and it works great… but not if you want to test gigabit internet speeds.

After extensive n00b troubleshooting why I couldn’t speed test over a couple of hundred Mbps, it turns out it’s due to using a python version of speedtest cli as the tutorial suggests. When I start fresh, I used Raspberry Pi OS (32-bit) Lite, and use the official Speedtest CLI install option for Debian, I attain expected speeds.

Now my missing link is how to get that data to Ubidots and automate tests so I can observe this data over time. When I follow the tutorial and exclude installing the python version of speedtest cli, it’ll break the python script we want to execute and automate; this is expected but I’m not sure how to fix it or if I should go a different route. I suspect it has something to do with creating test results via CSV, JSONL or JSON…?

In the end, I’d love to not just track download, upload and ping, but also server, jitter, and packet loss over time.

Any ideas are welcome, thanks for reading all the way through.

As the Speedtest CLI is not a python library, you just can’t simply use it in the python script exposed in the example. The way that comes to my mind to solve your problem is to create a bash command with two phases:

  1. Trigger the Speedtest CLI command and store the speed result in a .txt file
  2. Read that file using a python script to obtain the results and then just send them as shown in the example article.

Maybe a little overkill solution, but I cannot think in another way right now.

Hope it gives you additional hints.

All the best

1 Like

@jotathebest

Thank you for your response!

I ended up making a bash file that runs the speedtest command and outputs as json, piped it to my python script which sends to Ubidots, then automate running the bash file every 15th min with crontab.

What’s nice about this is I can now track jitter, packet loss, and server info over time.

1 Like