Connecting to Google Docs

Author Gravatar Image LADY ADA

Create and prepare spreadsheet

First up you will need to sign up for Google Docs and create a spreadsheet. We're going to call ours DHT Humidity Logs.

Once you've created it, delete all but one line (since we don't want 99 empty rows)
Then make the one remaining line a header with row names

Run Python code on Pi

First up we will have to install the gspread python library, which will do the heavy lifting of connecting to google docs and updating the spreadsheet! With your Pi connected and online, run the following:
Copy Code
tar -zxvf gspread-0.1.0.tar.gz
cd gspread-0.1.0
sudo python install
Next, in the Adafruit-Raspberry-Pi-Python-Code/Adafruit_DHT_Driver directory again, edit
Copy Code
# ===========================================================================
# Google Account Details
# ===========================================================================

# Account details for google docs
email       = ''
password    = '$hhh!'
spreadsheet = 'SpreadsheetName'
You'll have to put in your google email account, password and the spreadsheet name. You can also use the spreadsheet key if you don't want to refer to it by name, look lower down for the worksheet = gc.open_by_key() line and uncomment it, changing the key

That's pretty much it! Just run the python script with sudo. Whenever there's a hiccup with the sensor, it will wait 3 seconds and then try again, it doesn't fail that often anyways. You can edit the update delay at the last line of the script by editing time.sleep(30) to a different # of seconds
You can open the spreadsheet on your computer and watch it update live!
Last updated on 2014-04-16 at 07.07.23 PM Published on 2012-08-24 at 07.19.06 PM