How To Take Photo with Raspberry Pi at Given Time ?

Want to take photo of your room with Raspberry Pi if you are not at home ? It is possible with just few lines of code. This is my way to do it. I am using WDCloud to store images on my Windows drive available from anywhere. It is thanks to WD Cloud connected to my network. But you can store images on your local Raspberry Pi Sd Card and see them later. It is up to you. Jump in to my short article of how to take photo with raspberry pi at given time . For example every 5 minutes or so. 

Take Photo with Raspberry Pi at Given Time

First of all , create directory to store your images with simple terminal command like

mkdir /home/pi/mycctv

This is directory where you will store all your photos. That’s simple right ?

Another thing is to create sh file that contain terminal command to take photo

touch /home/pi/

you can give it executable permission like that

chmod +x /home/pi/

now we can edit it like that

nano /home/pi/

In you .sh file add this line

sudo raspistill -o /home/pi/mycctv/$(date +'%m%d%y%k%M%S''.jpg') -t 200

That command above will take the photo . You can test it in your termial. Image will be saved in /home/pi/mycctv as we mentioned in our command. Funny % and letters will give name to the file according to current date time including sceonds and extension will be .jpg . Simple right ?

Save the file (Ctrl+O , Ctrl +X)

Now it is time to exit cron file to run above command automatically .

sudo crontab -e

Add this line at the bottom of the file and save it (Ctrl+O, Ctrl+X)

 */5 * * * * /home/pi/

What is does mean ? It as cron to run file every 5 minutes


Autor: Seweryn

Mam na imię Seweryn i komputerami oraz informatyką interesuje się od roku 1996. Ukończyłem Birkbeck University of London na kierunku Information Technology profil Web Design. Moją kolejna wielką pasją jest gotowanie. Lubię grać w StarCrafta (od 1999 roku) , siłownię oraz moje koty. Man nadzieję, że przydadzą Ci się informacje zawarte na mojej stronie. W razie pytań pisz do mnie. Postaram się odpowiedzieć jak szybko mogę.

Dodaj komentarz