2015-06-14

Three years ago I wrote the original script to upload video to Google Drive as a trigger from Motion. Unfortunately Google recently removed support for the old security model and you now have to use OAuth 2.0. Also the gdata libraries have been superseded by the Google API Python Client. A few people have written alternatives to my original script quicker than I did, but here's my new version.

Note: I'm not using any third party libraries like PyDrive for example, this script goes straight to the Google APIs. (PyDrive has not been touched for a long time by its author and is missing features).

New feature: Public Snapshot

Motion comes with a feature to periodically take a snapshot regardless of whether motion has been detected. This is a nice feature if you want to have a web site with the latest view from your webcam. You can use Google Drive to host this image rather than installing a web server on your Pi and opening firewalls etc.

Create a public folder in your Google Drive:

Create a new folder called 'public'

Double click on it

Go to the sharing menu (person icon with + sign)

Click "Advanced" and then "Change..."

Set it to "On - Public on the Web"

Configure your uploader.cfg so docs/snapshot-folder is set to this folder 'public'.

Configure motion.conf to take a snapshot every n seconds named lastsnap.jpg and upload it:

You can also run this from the pygamelcd project: sudo python test2.py

From screen to GPIO

The PiTFT from Adafruit is a touchscreen. So let's see how we get input from the screen. We'll use this to light some LEDs on the breadboard.

With the PiTFT installed and the 4 tactile buttons there aren't many GPIs left on the model B Raspberry Pi. So wire up #17 and #4. The software renders 4 labels on the screen and then looks for mouse events in the four quarters: