{"id":16520074,"url":"https://github.com/pageauc/pi-motion-orig","last_synced_at":"2025-10-28T07:31:39.371Z","repository":{"id":11909609,"uuid":"14474231","full_name":"pageauc/pi-motion-orig","owner":"pageauc","description":"Raspberry Pi camera python motion detect and grive sync images to google drive","archived":false,"fork":false,"pushed_at":"2014-12-02T17:14:31.000Z","size":1000,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-01T12:45:31.367Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pageauc.png","metadata":{"files":{"readme":"Readme.txt","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-17T20:30:59.000Z","updated_at":"2023-05-02T16:39:44.000Z","dependencies_parsed_at":"2022-09-18T03:41:37.573Z","dependency_job_id":null,"html_url":"https://github.com/pageauc/pi-motion-orig","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pageauc%2Fpi-motion-orig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pageauc%2Fpi-motion-orig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pageauc%2Fpi-motion-orig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pageauc%2Fpi-motion-orig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pageauc","download_url":"https://codeload.github.com/pageauc/pi-motion-orig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238614559,"owners_count":19501480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T16:49:31.811Z","updated_at":"2025-10-28T07:31:33.910Z","avatar_url":"https://github.com/pageauc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"  Original Raspberry Pi Lightweight Python Motion Detection + grive syncing\n          Note: This Version Does not use picamera python libraries\n   grive capable raspberry pi security camera using python motion detection\n\nRecently I have been working on a grive capable security camera using two types\nof security camera cases.  One is a small fake plastic security cam case from\nAmazon.  Model A fits inside with wifi only.\nhttp://www.amazon.com/gp/product/B004D8NZ52/ref=oh_details_o01_s00_i00?ie=UTF8\u0026psc=1\nHere is a larger aluminum camera case that I have a model B installed in.\nThere is room for power adapter etc..\nhttp://www.amazon.com/Monoprice-108431-Outdoor-Camera-Switchable/dp/B007VDTTTM/ref=sr_1_72?ie=UTF8\u0026qid=1393884556\u0026sr=8-72\u0026keywords=fake+security+camera\nI may do a youtube video on setting up these cases to get the pi with camera module installed.\n\nThe Raspberry Pi security camera's are working efficiently.  \nThe current configuration uses a modified version of pimotion.py script to save\nfiles to a number sequence instead of a date-time sequence.  \nAlso added some code (not mine) to put date/time information directly on the\nphoto images.  This is convenient to see the exact time stamp that the photo \nwas taken. \nUsing number sequencing allows limiting the number of files that need to get\nsynchronized to my google drive. It was too much to manage all the dated files\nand cleanup in google drive.  This way I only have a set number of motion files\nthat need to get updated via grive. If you need more history you can write a \nroutine to save google drive files from a synchronized PC folder to a dated\narchive folder using a windows robocopy through a batch file.\n\nSynchronization uses a rpi compiled version of grive.  This requires slightly\nmodifying the source code to make it compatible with the RPI.  I may see if I\ncan package the setup including a precompiled grive to reduce the effort\nrequired to get this working.  \nTo automate the security camera operation,  I have setup pimotion.py to run\nfrom a /etc/init.d/pimotion.sh bash script by copying skeleton file to\npimotion.sh script.  Then modify to run your pimotion.py script on boot.  \nsee later in post for more setup detail.\nYou must have a raspberry pi model A or B with the latest raspbian build and\npi camera module installed and working.  There are several tutorials showing\nhow to do this so it is not covered here. This assumes you know how to cut and\npaste into nano or similar text editor on the pi. You also need an operational\ninternet connection via wifi or wired connection.  Wifi needs to be setup to\nwork on boot with no desktop in order for the camera to sync unattended with\nyour google drive.  I have written the pimotion python script and bash sync\nscripts to make it somewhat independent of the folder names etc.  \nThis minimizes hard coding folder names in the scripts.  If you run the script\nmanually from the command line then settings and activity information\nwill be displayed.\nJust a little setup for pimotion.py  If you already have a pimotion.py then\nmv existing file to another file name\n\nssh terminal commands\n\ntouch pimotion.py\nsudo chmod +x pimotion.py\nsudo nano pimotion.py   # paste the code below into the pimotion.py file and save ctrl-x\n\npimotion.py is the modified pimotion.py script based on previous modified\nbrainflakes script.  It allows the use of a number sequence to restrict the total number of files that need to get sync'd to my google drive using grive.  See later for details on grive.\nPlease note this includes PIL imageFont and imageDraw python modules to optionally put a date-time stamp on each photo.\nmodified pimotion.py\n\nJust a little setup to create the sync.sh file.\n\ntouch sync.sh\nsudo chmod +x sync.sh\nnano sync.sh     # paste sync.sh code below into the file and save\nmkdir google_drive\ntouch pimotion.dat\nsudo chmod 777 pimotion.dat\n\nThe sync.sh bash script is used to synchronize files on raspberry pi with my google drive\nThis will setup an /etc/init.d script so the pimotion.py script will run on boot up\n\ncd /etc/init.d\nsudo cp skeleton pimotion.sh\nchmod +x pimotion.sh\nsudo nano pimotion.sh   # change appropriate entries to point to your pimotion.py script\nsudo update-rc.d /etc/init.d/pimotion.sh defaults\ncd ~\n\nModify any pimotion.py script settings as required.  I have the camera setting image set to flipped due to the camera module mounting position in the fake security camera case.  You may also want to change sensitivity and/or threshold as needed as well as the filename prefix etc.\n\nYou will need to download the tar file and extract it on your raspberry pi or compile a modified version of  grive in order to sync files to your google drive\nsee instructions url link below.  Compiling takes a little while and you must edit the specified /home/pi/grive/libgrive/src/drive/State.cc file per the web link below.  If you have problems read the posts.  When you initialize grive with google I opened an ssh session to the raspberry pi on my windows 7 PC and then cut and pasted the grive -a url to chrome browser while logged into google.  This takes you to a screen that returns a very long security code.  I then cut and pasted this into the RPI session and everything worked just fine.  I did not login to google on the pi.  I only needed the PC to be logged in and paste the authentication code back to the pi from the PC.  I don't think you need a logged in google account on the pi as the post mentions.  At any rate it worked for me and I had to try several times since I was trying to avoid having grive executable in the google_drive folder.  By using the -p option and copying the grive hidden config files to the rpi google_drive folder I managed to get everything to work.   \nhttp://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html\nor this link might be even better\nhttp://www.pihomeserver.fr/en/2013/08/15/raspberry-pi-home-server-synchroniser-le-raspberry-pi-avec-votre-google-drive/\n\nOnce compile is successful copy the grive executable to the folder that pimotion.py and sync.sh are located\nmodify this to suit your folder structure.\n\nsudo mv grive grive_src\ncp /home/pi/grive_src/grive/grive /home/pi\nchmod +x grive\nsudo ./grive -a \n# cut and paste the resulting grive url into web browser that is logged into your google account\n# cut and paste the resulting web browser security code back to raspberry pi grive session.\n# grive will indicate if the operation was successful\nsudo cp ./.grive google_drive\nsudo cp ./.grive_state google_drive\nsudo ./sync.sh\n\nOnce grive has been initialized successfully with the grive -a option then copy the /home/pi/.grive and /home/pi/.grive_state files to the /home/pi/google_drive folder per above code. This will allow grive to be executed from the /home/pi folder so it does not have to be in the google_drive folder.\n\nTo test you can launch pimotion.py from a ssh terminal session\n\ncd ~\nsudo ./pimotion.py\n\nFrom a second ssh terminal run sync.sh (make sure that motion was detected and files are in the google_drive folder to sync.  You should see a /home/pi/sync.lock file.  This was created by pimotion.py when motion photos were created.\n\ncd ~\nsudo ./sync.sh\n\nYou should see files being synchronized in both directions.  This is normal.  There are google drive apps for Apple, Android, Mac and PC.  This will allow you to access the raspberry pi motion capture security camera files on other computers or handheld devices.\nAssuming you have wifi/wired network to start on boot headless and the crontab and init.d setup then the camera will work immediately on booting (unattended).  I also setup a cronjob to reboot the rpi once a day but this may not be necessary for you.  I did it since I intend to leave the rpi security camera run remotely and gives a chance for system to recover should there be a small glitch.\nAlso if you have problems check permissions.  The init.d will run as root so the files in the google_drive folder will be owned by root.  Just check to make sure you run with sudo ./pimotion.sh and sudo ./sync.sh if you are in terminal sessions.\nOnce you know sync.sh is working OK you can automate the sync by running it in as a cronjob.\n\nsudo crontab -e\n\nPaste the following line into the crontab file nano editor \n\n*/1 * * * * /home/pi/sync.sh \u003e/dev/nul\n\nctrl-x to exit and save crontab file\nthis will run once a minute.  You can change to suit your needs.  If grive is already running or there are no files to process then the script simply exits. Also if grive has been running for more than 5 minutes it is killed.  This can be changed in the script if you wish.\n\nGood Luck\nClaude Pageau ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpageauc%2Fpi-motion-orig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpageauc%2Fpi-motion-orig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpageauc%2Fpi-motion-orig/lists"}