{"id":112,"date":"2014-01-03T15:08:01","date_gmt":"2014-01-03T14:08:01","guid":{"rendered":"http:\/\/candrea.ch\/blog\/?p=112"},"modified":"2014-01-03T15:08:01","modified_gmt":"2014-01-03T14:08:01","slug":"raspberry-pi-camera-sends-pictures-to-owncloud","status":"publish","type":"post","link":"https:\/\/candrea.ch\/blog\/raspberry-pi-camera-sends-pictures-to-owncloud\/","title":{"rendered":"Raspberry Pi Camera sends Pictures to ownCloud"},"content":{"rendered":"<p>Of course, there are many variants to take pictures with your raspberry pi camera and save them somewhere.<\/p>\n<p>I use my raspberry pi camera to observe my flat when I am away. I want to do this in a as secure way as possible, i.e., I do not want to open any special ports on my router nor do I want to send unencrypted images over the web.<\/p>\n<p>Inspired by \u00a0<a href=\"http:\/\/blog.davidsingleton.org\/raspberry-pi-webcam-a-gentle-intro-to-crontab\/\" target=\"_blank\">http:\/\/blog.davidsingleton.org\/raspberry-pi-webcam-a-gentle-intro-to-crontab\/<\/a>\u00a0 my idea was to take a photo every 5 or 10 minutes and save them to my ownCloud server via WebDAV with SSL encryption.<\/p>\n<p>Step by step:<\/p>\n<p>1.) Make sure you have a raspberry pi with a camera module and an owncloud installation reachable over https \u00a0somewhere out in the web (with picture app activated).<\/p>\n<p>2.) Mount your owncloud drive on your raspberry pi: Create the directory <span class=\"lang:sh highlight:0 decode:true crayon-inline crayon-selected\">\/home\/pi\/owncloud<\/span>\u00a0\u00a0and add the following line to fstab:<\/p>\n<pre class=\"lang:sh highlight:0 decode:true\">https:\/\/[your.owncloud.domain.name]\/remote.php\/webdav\/ \/home\/pi\/owncloud davfs rw,noexec,noauto,user,async,_netdev,uid=pi,gid=pi 0 0<\/pre>\n<p>then mount the drive by calling\u00a0<span class=\"lang:sh highlight:0 decode:true crayon-inline\">mount owncloud\/<\/span>\u00a0 or by calling\u00a0<span class=\"lang:sh highlight:0 decode:true crayon-inline\">echo -e &#8220;y&#8221; | mount owncloud\/<\/span>\u00a0 \u00a0if your server has a self-signed certificate as mine has.<\/p>\n<p>3.) My idea is to take a picture, say, every 10 minutes, and take them for 24 hours with any need to remove them manually. So, write a script like the following, name it &#8220;take_photo.sh&#8221;\u00a0and make it executable:<\/p>\n<pre class=\"lang:sh highlight:0 decode:true\">#!\/bin\/bash\r\nfilename=\"\/home\/pi\/owncloud\/myflat_$(date +%H%M).jpg\"\r\nraspistill -o \/home\/pi\/image.jpg\r\nmv \/home\/pi\/image.jpg $filename<\/pre>\n<p>4.) Set up the crontab by calling\u00a0<span class=\"lang:sh highlight:0 decode:true crayon-inline\">crontab -e<\/span>\u00a0 and add the following line:<\/p>\n<pre class=\"lang:sh highlight:0 decode:true\">*\/10 * * * * \/home\/pi\/take_photo.sh<\/pre>\n<p>5.) You are finished. Raspberry pi will take every 10 minutes a photo and save them to your ownCloud where you have a beautiful picture viewer that you can access wherever you are on whatever for a device.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Of course, there are many variants to take pictures with your raspberry pi camera and save them somewhere. I use my raspberry pi camera to observe my flat when I am away. I want to do this in a as secure way as possible, i.e., I do not want to open any special ports on &hellip; <a href=\"https:\/\/candrea.ch\/blog\/raspberry-pi-camera-sends-pictures-to-owncloud\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Raspberry Pi Camera sends Pictures to ownCloud<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-112","post","type-post","status-publish","format-standard","hentry","category-new-media"],"_links":{"self":[{"href":"https:\/\/candrea.ch\/blog\/wp-json\/wp\/v2\/posts\/112"}],"collection":[{"href":"https:\/\/candrea.ch\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/candrea.ch\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/candrea.ch\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/candrea.ch\/blog\/wp-json\/wp\/v2\/comments?post=112"}],"version-history":[{"count":7,"href":"https:\/\/candrea.ch\/blog\/wp-json\/wp\/v2\/posts\/112\/revisions"}],"predecessor-version":[{"id":119,"href":"https:\/\/candrea.ch\/blog\/wp-json\/wp\/v2\/posts\/112\/revisions\/119"}],"wp:attachment":[{"href":"https:\/\/candrea.ch\/blog\/wp-json\/wp\/v2\/media?parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/candrea.ch\/blog\/wp-json\/wp\/v2\/categories?post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/candrea.ch\/blog\/wp-json\/wp\/v2\/tags?post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}