top of page

Individual Discovery Project

Raspberry Pi Internet Speed Monitor

2021 Spring Semester

I created a Raspberry Pi Internet Speed Monitor by writing a Python program that polls the speedtest.net service using a repository of the speedtest CLI software to extract the ping, download speed, and upload speed of an internet connection. I built this internet speed monitor to determine when a network may be at its peak capacity as well as whether I am suffering from a degraded internet connection. 

 

The procedure of the project began with executing sudo commands to add the necessary packages so that the speedtest command line interface can be installed. Next, I added the Ookla repository, a required component for the speedtest CLI, and updated the package list in the repository. Finally, the speedtest CLI is added to the Raspberry Pi. To test the speedtest installation, I created a short Python program that calls the speedtest CLI and retrieves a response in the form of a text string. Then the program parses the response and extracts numerical data for the ping, upload, and download speeds. Finally, the program writes the data to a CSV file where the data can be easily viewed by the user. Once I completed this stage of the development, I moved onto implementing InfluxDB and using Grafana to display the data. I began by starting InfluxDB and creating a database within it from the terminal. I added a new user so that I can interact with the data, and then I installed the InfluxDB Python library. To save the data to the InfluxDB database, I created another Python script that calls the speedtest CLI, processes the data, connects to the InfluxDB server, and writes the data to the database. Finally, to view the data in Grafana, I used Grafana’s web interface to implement the database as a data source. I concluded by creating a Grafana dashboard that extracts data from the database and graphically visualizes the data over varying time intervals. Using a crontab command, I automated the process of running the program so that the program is run every minute. As a result, the InfluxDB database, and the Grafana dashboard are also updated every minute as well.

 

After I completed the project, I obtained results that matched what I expected. Once I implemented the final steps and left the Grafana dashboard open for long periods of time, I returned to find new data points on my dashboard every minute with new data added until the Raspberry Pi is shut down. Moreover, the jobs are automatically initialized when the Raspberry Pi is plugged in, so the operation is completely seamless. The dashboard automatically scaled the graph, plotted each corresponding value for upload speed, download speed, and ping, and connected points together so that the graph was easily comprehensible. The final visualization is visible in the video showcase I presented above.

 

Through this project, I gained exposure to using the Unix terminal in Raspberry Pi OS, writing sudo commands to install, update, and upgrade packages, creating Python files from the terminal, and working with new libraries like the "re", "subprocess", and "time" libraries. I also developed experience working with InfluxDB, including creating a server and adding a database to that server, as well as creating/managing databases, and writing data from a file to a database. Finally, I also implemented a Grafana dashboard and wrote crontab commands to automate these operations independent of the user.

  • Microsoft Outlook
  • White LinkedIn Icon
bottom of page