ThingSpeak is an open-source Internet of Things application and API to store and retrieve data from things using the HTTP and MQTT protocol over the Internet or via a Local Area Network.
I signed up for an account on ThingSpeak using my MathWorks credentials and downloaded psutil onto the Pi which is a cross-platform library for process and system monitoring in Python.
Data is collected and written in a ThingSpeak channel by using the Write API key that ThinkSpeak automatically generates. I inputted this key into the python script and received system utilization percentages updates and updates on how much memory is available plotted against time.
ThingsSpeak was updated every minute and gave live updates on my public channel. The results of this experiment are shown above. ThingSpeak is an excellent platform if you need to monitor system updates every X amount of time but the amount of time the API can collect and update data is limited to 15 seconds.
I created a new project using the Google Cloud Platform Identity and Accesses Management (IAM) tools and enabled both Google Drive and Google Sheets APIs. After enabling these APIs, the tools within IAM created a .json file containing my private key. Next I installed gspread and oauth2client which are Google Sheets Python API and authentication library for Python, respectively. Oauth2client is now deprecated and I was pointed to use google-auth and authlib in the future.
The packages were installed and two python scripts were moved in the /demo directory:
$ sudo pip3 install -U gspread oauth2client
$ cd demo
$ cp ~/iot/lesson3/system_info.py .
$ cp ~/iot/lesson7/rpi_spreadsheet.py .
The JSON key file was then transferred from my laptop computer into the same directory as rpi_spreadsheet.py. The scp command was used to send the files over ssh by specifying the file, Raspberry Pi IP address and the destination file path.
$ scp rpidata-*.json pi@xxx.xxx.x.xx:/home/pi/demo
SUCCESS!! I LEARNED A NEW METHOD FOR FILE TRANSFER BETWEEN DIFFERENT MACHINES
Next I navigated to Google Sheets and created a new spreadsheet called rpidata and shared the the spreadsheet with the "client_email" address is the .json file and selected the "Can edit" option. I then added header titles to the spreadsheet for 'Date / Time', 'CPU Usage %', and 'Temperature C' that would be updated with information from the Raspberry Pi.
The python script was modified to include the both the .*json and google spreadsheet file names.
Success part 2, the raspberry pi is able to update the google spreadsheet with system performance updates every 10 seconds with a latency < 1 second. I am wondering if this technology can be used to track traffic flows during peak hours.