Étape 4: Pi-caméra & Google Drive
Maintenant le plaisir partie. Étant donné que la Pi est un dongle wifi, je recommande ce qui lui donne une adresse IP statique et en utilisant SSH pour le gérer sur le reste de ces étapes.
- J’ai ajouté le code pour l’intégration de la caméra et lecteur à github ici : https://github.com/dunds/timelapse . Le script a une dépendance : un fichier client_secrets.json de votre lecteur de Google API.
- Alors qu’il est connecté à votre compte Google, accédez à: https://console.developers.google.com/apis . De là, vous pouvez activer Google Drive et gérer les informations d’identification de l’API.
- Cliquez sur l’onglet « titres » et sélectionnez « Create Références -> ID OAuth Client ». Utilisez « autre » comme type. Vos informations d’identification nouvellement créées auront un téléchargement lien vers la droite (voir photo). Nommez-la client_secrets.json et collez-la dans votre répertoire de timelapse.
- Exécuter « python timelapse.py » à partir du répertoire de timelapse. La première fois que vous exécutez, vous serez guidé à travers un processus où Google valide votre application avec un jeton de sécurité. Regardez-vous, authentifier solidement à Google Drive. Ce qu’un patron.
- Dernière étape consiste à ajouter une entrée à cron pour planifier ce script pour exécuter tous les jours. Voici à quoi ressemble mon crontab :
pi $ cat /etc/crontab # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) # 15 14 * * * pi cd /home/pi/timelapse/ && python timelapse.py