Speedtest-cli is a command line tool by Ookia which is available for Windows,Linux and Mac.
The install instructions are available here and here.
Because I use Python and Speedtest-cli is written in python I used the standard Pip install method on windows and my Raspberry Pi.
pip install speedtest-cli
Using Speedtest-cli From the Command Line
Before you try to use speedtest-cli tool in node-red then you should run it from the command line to check it works and to test out the options that you want to use.
The Gitub page also has a full list of the command line options but you can get them using the command.
The options that you might find useful are
- –json -output as JSON
- –server test against a specific server
Below is a screen shot of the command using the default options:
Below is a screen shot of the command using the –server and –json options:
The json option is very useful when you want to pass the data into a program as we do with node-red.
Node-Red Speed Test Flow
To run it in node red we use the exec node which allows us to run external commands.
Here is a screen shot of the node configuration; notice how the command line options are passed to the command. Notice the json option
The node has three outputs
- Standard Output
- Standard Error
- Return Code.
The command results are taken from output 1.
You can use output 3 to determine if the command succeeded or not. A value of 0 is good.
This is what the flow looks like.
I’ve added debug node so I can show you the output.
The main function node processes the data and sends it to a monitor so you can view the results in real time and also to a SQLite database.
Notice that when the node is running the process id of the system command is shown in the node status.
The debug nodes shows the standard output which contains our data and the result code which is 0 indicating success.
The results are displayed as a graph using the chart node.
The above graph shows the download speed dropping off a cliff and was taken from my Internet monitor during a recent Internet connection problem.
Node-Red Flow Download
The following video is a general video covering running external commands from node-red. The speed-test flow is at the end of the video.
- Run a speed test from the command line
- Store Data In SQL Database using Node-red video and flows
- Store Data In SQL database flow
I tried your program and on the debug node I can see the upload and download speeds. But it’s not plotting on the graf. Could help me, please. I am new to Node-Red and I like the program you built.
Check the configuration of the chart node. Do you get any error messages. If it is still a problem then use the ask steve page to contact me and I’ll send you another copy of the flow.
great thing, however I wonder how to create the SQLite DB, I get “Error: SQLITE_ERROR: no such table: SPEED”.
Do you have the SQL-Create script at hand for me and potential other readers?
Sorry for the delay.I did a few videos for storing and reading data from sql and the flows are available to download in the video description. The flows contain simple inject nodes to create the tables. Here is a link to the first video
Node-red Storing IOT data In a SQL Database
Here is the flow used in the video
Here are links to the other videos
Reading IOT Data From a SQL Database with Node-Red
Node-Red Storing IOT data In a SQL Database-Part 2