Raspberry Pi bot tweets when speeds are lousy

This post is inspired from Engadget article. I have added more detailed instructions to the same.

Follow the steps below:

  • Install python

    sudo apt-get install python python-pip

  • Install Twitter's python wrapper

    pip install twitter

  • Install Speedtest-cli

    pip install speedtest-cli

  • Login to https://apps.twitter.com and create a new application.

    Copy the Consumer Key & Consumer Secret

    Generate Access Token & Access Token Secret

  • Create a directory for the script

    sudo mkdir /opt/speedtest

  • Copy the script from Github to /opt/speedtest

  • Edit the script and add the Keys and Secrets to line 38-41.

  • Add a hourly or daily cron job.

    0 * * * * /opt/speedtest/speedtest-xfinity.py

Note: Additionally, you can run the speedtest-cli to find the nearest server.
speedtest-cli --list
The above command line option shows the list of servers sorted according to distance.
Use the server number from above at line 13 in the script.