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.
speedtest-cli --help
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.
Running Speedtest in Node-red
To run it in node red we use the exec node which allows us to run external commands.
Here is a screenshot of the node configuration; notice how the command line options are passed to the command
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.
Flow Download
Flow Video
The following video is a general video covering running external commands from node-red. The speed-test is at the end of the video.
Resources
- Run a speed test from the command line
- Store Data In SQL Database using Node-red video
- Store Data In SQL database flow
Related Tutorials
Hi there,
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?
Hi
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
https://youtu.be/d8eeNROMTv0
Here is the flow used in the video
http://www.steves-internet-guide.com/download/store-iot-data-in-sqlite-database/
Here are links to the other videos
Reading IOT Data From a SQL Database with Node-Red
https://youtu.be/pQvbvuo11Yk
———
Node-Red Storing IOT data In a SQL Database-Part 2
https://youtu.be/fwF5xijNIWI
Steve