Skip to content

Instantly share code, notes, and snippets.

@jeffeb3
Last active December 4, 2022 00:09
Show Gist options
  • Save jeffeb3/4adedd744547b6671343310463cf9ecf to your computer and use it in GitHub Desktop.
Save jeffeb3/4adedd744547b6671343310463cf9ecf to your computer and use it in GitHub Desktop.
speedRecorder
speedtest-cli
fastcli
adafruit-io
aioUsername = "YOUR USERNAME"
aioKey = "YOUR KEY"
# Read two speed test results and store them in adafruit.io's feeds.
# You have to make the feeds first, and get the keys.
from Adafruit_IO import Client
from fastcli import fastcli
from speedtest import Speedtest
from secrets import aioUsername, aioKey
aio = Client(aioUsernam, aioKey)
# Fast.com
fastspeed = fastcli.run()
print("Fast.com: ",fastspeed,"Mbps")
# SpeedTest.net
servers = []
threads = None
s = Speedtest()
s.get_servers(servers)
s.get_best_server()
s.download(threads=threads)
s.upload(threads=threads)
results = s.results.dict()
download = results['download']*1.0e-6
print("speedtest.net download: ",download,"Mbps")
upload = results['upload']*1.0e-6
print("speedtest.net upload: ",upload,"Mbps")
ping = results['ping']
print("speedtest.net ping: ",ping,"Mbps")
# aio
aio.send('internet-speeds.st-download', download)
aio.send('internet-speeds.st-upload', upload)
aio.send('internet-speeds.st-ping', ping)
aio.send('internet-speeds.fastdotcom', fastspeed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment