Week 2: Rasberry Temperatures - mparra-mpz/week-of-code GitHub Wiki

Hardware Components

Software Components

Software Development

In this project I sent cpu and gpu temperatures in the Raspberry Pi B+ to a google spreadsheet, first you need to get a signal credential from google, read this excelent tutorial to learn how to get the credential. Important note: The signal credential will generate a "fake" e-mail, make sure share your spreadsheet with this fake mail.

After that you need to install gspread and oauth2client, I advice to use pip to install this python modules.

sudo apt-get install python-pip
sudo pip install gspread
sudo pip install --upgrade oauth2client

You can get the cpu temperature from the file /sys/class/thermal/thermal_zone0/temp. For the gpu temperature you must execute the following command /opt/vc/bin/vcgencmd measure_temp.

# Stablish connection with google docs.
scope = ["https://spreadsheets.google.com/feeds"]
credentials = ServiceAccountCredentials.from_json_keyfile_name(credential_file, scope)
connection= gspread.authorize(credentials)
# Select the spreadsheet and worksheet.
spreadsheet = connection.open("Raspberry")
worksheet = spreadsheet.get_worksheet(0)
# Publish the information in the worksheet.
worksheet.append_row((timestamp, cpu, gpu))

You can run the application in different ways, for example: python gspread-temperatures.py -f ~/CODE/raspberry-pi-cd4c80393fcc.json.

My final result looks like:

You can check the current status in this link