Python program to monitor CPU temperature on a Raspberry Pi and push data to AdafruitIO.
There are free and paid plans for AdafruitIO. Once you have an account, create a new feed. A dashboard can be configured to display the data from the feed in different formats. Complete documentation is available on readthedocs.io.
On the Raspberry Pi, install the AdafruitIO library (pip3 is the Python package manager):
pip3 install adafruit-io
If uploading your code to a public repository such as Github, do not expose your AdafruitIO credentials. Instead, put the username and API key in a separate file such as creds.py and then include the file name in the .gitignore file.
creds.py
# Credentials for your AdafruitIO account
username = "Your_UserName"
key = "Your_API_key"
.gitignore
# Hide credentials file
creds.py
In the main program, import the library and credentials then create an instance of the REST client
import creds
from Adafruit_IO import Client
# Setup connection to AdafruitIO REST client
adafruit_io_username = creds.username
adafruit_io_key = creds.key
aio = Client(adafruit_io_username, adafruit_io_key)
Create a log file in the path of your choice before running. If not present, it will throw an error.
/home/pi/logs/cpu_temp_load.csv
If logging is not desired, comment out the line that calls that function.
write_temp(temp,avg)
Take a look at the code in cpu_tempmon.py for further comments.
Have fun!